Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flush on windows: flush() needs an additional call to FlushFileBuffers() #5

Closed
glycerine opened this issue Nov 2, 2015 · 0 comments

Comments

@glycerine
Copy link
Contributor

"The FlushViewOfFile function does not flush the file metadata, and it does not wait to return until the changes are flushed from the underlying hardware disk cache and physically written to disk. To flush all the dirty pages plus the metadata for the file and ensure that they are physically written to disk, call FlushViewOfFile and then call the FlushFileBuffers function."
-- https://msdn.microsoft.com/en-us/library/windows/desktop/aa366563(v=vs.85).aspx

It appears, in

https://github.com/edsrzf/mmap-go/blob/master/mmap_windows.go#L75

that FlushViewOfFile() is used without FlushFileBuffers().

In contrast, the unix implementation (https://github.com/edsrzf/mmap-go/blob/master/mmap_unix.go#L38) calls msync(addr,len,MS_SYNC), which does guarantee after it returns that the data is then physically on the disk.

Reference: http://www.gnu.org/software/libc/manual/html_node/Memory_002dmapped-I_002fO.html

glycerine added a commit to glycerine/mmap-go that referenced this issue Nov 2, 2015
@edsrzf edsrzf closed this as completed in #6 Nov 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant