llvm.org GIT mirror llvm / 69a2d6f
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 Douglas Gregor 7 years ago
2 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4040 };
4141
4242 private:
43 SmallString<128> FileName;
4344 SmallString<128> LockFileName;
4445 SmallString<128> UniqueLockFileName;
4546
6363
6464 LockFileManager::LockFileManager(StringRef FileName)
6565 {
66 this->FileName = FileName;
6667 LockFileName = FileName;
6768 LockFileName += ".lock";
6869
174175 #endif
175176 // Don't wait more than an hour for the file to appear.
176177 const unsigned MaxSeconds = 3600;
178 bool LockFileGone = false;
177179 do {
178180 // Sleep for the designated interval, to allow the owning process time to
179181 // finish up and remove the lock file.
184186 #else
185187 nanosleep(&Interval, NULL);
186188 #endif
187 // If the file no longer exists, we're done.
189 // If the lock file no longer exists, wait for the actual file.
188190 bool Exists = false;
189 if (!sys::fs::exists(LockFileName.str(), Exists) && !Exists)
190 return;
191 if (!LockFileGone) {
192 if (!sys::fs::exists(LockFileName.str(), Exists) && !Exists) {
193 LockFileGone = true;
194 Exists = false;
195 }
196 }
197 if (LockFileGone) {
198 if (!sys::fs::exists(FileName.str(), Exists) && Exists)
199 return;
200 }
191201
192202 if (!processStillExecuting((*Owner).first, (*Owner).second))
193203 return;