Skip to content
Snippets Groups Projects
Commit 11af4bd4 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

On Windows, lock the opened mutex file to insure *nix sopen() will fail

Even though we use O_EXCL, networked file systems still sometimes allow the
secondary open() to succeed. We use record locking in xpdev's sopen()
implementation for *nix, so this lock will insure such opens (and locks) will
now fail.

This is an attempt to address occassional error on Vertrauen:
ERROR 2 (No such file or directory) renaming *.rep to *.bad
parent 61615d98
No related branches found
No related tags found
No related merge requests found
Pipeline #7321 passed
......@@ -154,6 +154,15 @@ bool _fmutex_open(fmutex_t* fm, const char* text, long max_age, bool auto_remove
);
if(h == INVALID_HANDLE_VALUE)
return false;
if(!LockFile(h,
0, // dwFileOffsetLow
0, // dwFileOffsetHigh
1, // nNumberOfBytesToLockLow
0 // nNumberOfBytesToLockHigh
)) {
CloseHandle(h);
return false;
}
if((fm->fd = _open_osfhandle((intptr_t)h, O_WRONLY)) == -1) {
CloseHandle(h);
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment