diff options
author | Chris Wilson <chris+github@qwirx.com> | 2015-08-15 10:58:28 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2015-08-15 10:58:28 +0000 |
commit | 753fd7f5cf888cedf95befc88600239b61958bd5 (patch) | |
tree | 9970876f92f8f061374a4af2634da280ab3c8ecc /lib | |
parent | f3123609167c0e2e621c90e6b1248234cebc8a6e (diff) |
Reset NamedLock file descriptor immediately after closing.
Otherwise, if we fail to unlink the lockfile, we will try to close it again,
which will fail because it's already closed, and we'll never get around to
unlinking it.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common/NamedLock.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/common/NamedLock.cpp b/lib/common/NamedLock.cpp index 18ef1edf..8cacf065 100644 --- a/lib/common/NamedLock.cpp +++ b/lib/common/NamedLock.cpp @@ -236,6 +236,9 @@ void NamedLock::ReleaseLock() CommonException, OSFileError); } + // Mark as unlocked, so we don't try to close it again if the unlink() fails. + mFileDescriptor = -1; + #ifdef WIN32 // On Windows we need to close the file before deleting it, otherwise // the system won't let us delete it. @@ -248,9 +251,6 @@ void NamedLock::ReleaseLock() } #endif // WIN32 - // Mark as unlocked, so we don't try to close it again if the unlink() fails. - mFileDescriptor = -1; - BOX_TRACE("Released lock and deleted lockfile " << mFileName); } |