Fix: Unmap before truncating
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Wed, 19 Jun 2019 17:28:14 +0000 (13:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 18 Jul 2019 15:53:32 +0000 (11:53 -0400)
commit2b03995547d433604edca94a5d7de4d9550dc9d4
tree05be31300317d3776d394e2af7c97766cf7348cd
parenta10f92295ad6d80839e4546dee24e57655e4ee9e
Fix: Unmap before truncating

The mmap/mman compat layer for mingw uses the CreateFileMapping
and UnmapViewOfFile thus implicitly imposes an order for truncation and
ummapping [1].

For truncation calls, the underlying windows API call is SetEndOfFile.
This function requires that the file be unmapped before being called [1].

[1]
  If CreateFileMapping is called to create a file mapping object for
  hFile, UnmapViewOfFile must be called first to unmap all views and
  call CloseHandle to close the file mapping object before you can call
  SetEndOfFile.

[1] https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-setendoffile#remarks

Change-Id: Id4713ca3af612baa24e1fa4a749384eab452598a
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1519
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Michael Jeanson <mjeanson@efficios.com>
src/ctfser/ctfser.c
This page took 0.026129 seconds and 4 git commands to generate.