Handles special errors from FlushFileBuffers() for Windows.

This commit is contained in:
Andrea Mazzoleni 2014-09-26 22:59:07 +02:00
parent 0433033c12
commit eeea58b42a

View file

@ -810,8 +810,30 @@ int windows_fsync(int fd)
}
if (!FlushFileBuffers(h)) {
windows_errno(GetLastError());
return -1;
DWORD error = GetLastError();
switch (error) {
case ERROR_INVALID_HANDLE :
/*
* FlushFileBuffers returns this error if the handle
* doesn't support buffering, like the console output.
*
* We had report also for ATA-over-Ethernet reporting this
* error.
*/
return 0;
case ERROR_ACCESS_DENIED
/*
* FlushFileBuffers returns this error for read-only
* data, that cannot have to be flushed.
*/
return 0;
default:
windows_errno(error);
return -1;
}
}
return 0;