Commit 8c4540f6 authored by Robert Ricci's avatar Robert Ricci

Change the way that we detect that another process has finished, because

the old way was slightly wrong, and had a race.
parent 2cbc0267
......@@ -132,14 +132,19 @@ if (flock(LOCK, LOCK_EX|LOCK_NB) == 0) {
# If we didn't get the lock, wait for the processes that did to finish
#
if (!$gotlock) {
while (((stat(LOCK))[9] != $oldlocktime) &&
(flock(LOCK, LOCK_EX|LOCK_NB) == 0)) {
while (1) {
if ((stat(LOCK))[9] != $oldlocktime) {
exit(0);
}
if (flock(LOCK, LOCK_EX|LOCK_NB) != 0) {
close(LOCK);
exit(0);
}
if ($count++ > 20) {
fatal("Could not get the lock after a long time!\n");
fatal("Process with the lock didn't finish after a long time!\n");
}
sleep(1);
}
exit(0);
}
}
}
......
......@@ -110,14 +110,19 @@ if (!$TESTMODE) {
# If we didn't get the lock, wait for the processes that did to finish
#
if (!$gotlock) {
while (((stat(LOCK))[9] != $oldlocktime) &&
(flock(LOCK, LOCK_EX|LOCK_NB) == 0)) {
while (1) {
if ((stat(LOCK))[9] != $oldlocktime) {
exit(0);
}
if (flock(LOCK, LOCK_EX|LOCK_NB) != 0) {
close(LOCK);
exit(0);
}
if ($count++ > 20) {
fatal("Could not get the lock after a long time!\n");
fatal("Process with the lock didn't finish after a long time!\n");
}
sleep(1);
}
exit(0);
}
}
}
......
......@@ -94,14 +94,20 @@ if (flock(LOCK, LOCK_EX|LOCK_NB) == 0) {
# If we didn't get the lock, wait for the processes that did to finish
#
if (!$gotlock) {
while (((stat(LOCK))[9] != $oldlocktime) &&
(flock(LOCK, LOCK_EX|LOCK_NB) == 0)) {
while (1) {
if ((stat(LOCK))[9] != $oldlocktime) {
exit(0);
}
if (flock(LOCK, LOCK_EX|LOCK_NB) != 0) {
close(LOCK);
exit(0);
}
if ($count++ > 20) {
fatal("Could not get the lock after a long time!\n");
fatal("Process with the lock didn't finish after a long time!\n");
}
sleep(1);
}
exit(0);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment