mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-15 04:20:27 +00:00
Fix a race condition in the lock-file manager: once the lock file is
gone, check for the actual file we care about. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172033 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
06c7008e30
commit
69a2d6f55a
@ -41,6 +41,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SmallString<128> FileName;
|
||||||
SmallString<128> LockFileName;
|
SmallString<128> LockFileName;
|
||||||
SmallString<128> UniqueLockFileName;
|
SmallString<128> UniqueLockFileName;
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@ bool LockFileManager::processStillExecuting(StringRef Hostname, int PID) {
|
|||||||
|
|
||||||
LockFileManager::LockFileManager(StringRef FileName)
|
LockFileManager::LockFileManager(StringRef FileName)
|
||||||
{
|
{
|
||||||
|
this->FileName = FileName;
|
||||||
LockFileName = FileName;
|
LockFileName = FileName;
|
||||||
LockFileName += ".lock";
|
LockFileName += ".lock";
|
||||||
|
|
||||||
@ -175,6 +176,7 @@ void LockFileManager::waitForUnlock() {
|
|||||||
#endif
|
#endif
|
||||||
// Don't wait more than an hour for the file to appear.
|
// Don't wait more than an hour for the file to appear.
|
||||||
const unsigned MaxSeconds = 3600;
|
const unsigned MaxSeconds = 3600;
|
||||||
|
bool LockFileGone = false;
|
||||||
do {
|
do {
|
||||||
// Sleep for the designated interval, to allow the owning process time to
|
// Sleep for the designated interval, to allow the owning process time to
|
||||||
// finish up and remove the lock file.
|
// finish up and remove the lock file.
|
||||||
@ -185,10 +187,18 @@ void LockFileManager::waitForUnlock() {
|
|||||||
#else
|
#else
|
||||||
nanosleep(&Interval, NULL);
|
nanosleep(&Interval, NULL);
|
||||||
#endif
|
#endif
|
||||||
// If the file no longer exists, we're done.
|
// If the lock file no longer exists, wait for the actual file.
|
||||||
bool Exists = false;
|
bool Exists = false;
|
||||||
if (!sys::fs::exists(LockFileName.str(), Exists) && !Exists)
|
if (!LockFileGone) {
|
||||||
|
if (!sys::fs::exists(LockFileName.str(), Exists) && !Exists) {
|
||||||
|
LockFileGone = true;
|
||||||
|
Exists = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (LockFileGone) {
|
||||||
|
if (!sys::fs::exists(FileName.str(), Exists) && Exists)
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!processStillExecuting((*Owner).first, (*Owner).second))
|
if (!processStillExecuting((*Owner).first, (*Owner).second))
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user