QLockFile: sync to disk to avoid leaving an empty lock file on crash
The two lines of code are the same as in QFSFileEnginePrivate::nativeSyncToDisk, but we don't want to create a fileengine instance just for this. qlockfile_win.cpp already calls FlushFileBuffers, only the Unix implementation was missing the equivalent call. Task-number: QTBUG-44771 Change-Id: I2253972857e4de9d27ef442c92983a1088d6f03e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
b47bcba0f5
commit
4accd865c2
|
|
@ -178,6 +178,13 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys()
|
|||
// We hold the lock, continue.
|
||||
fileHandle = fd;
|
||||
|
||||
// Sync to disk if possible. Ignore errors (e.g. not supported).
|
||||
#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
|
||||
fdatasync(fileHandle);
|
||||
#else
|
||||
fsync(fileHandle);
|
||||
#endif
|
||||
|
||||
return QLockFile::NoError;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue