From 753fd7f5cf888cedf95befc88600239b61958bd5 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 15 Aug 2015 10:58:28 +0000 Subject: 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. --- lib/common/NamedLock.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/common') 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); } -- cgit v1.2.3