Commit 0d836da9 authored by Leigh Stoller's avatar Leigh Stoller

Locking fix; spinwait for slice lock in CreateSliver().

It is possible for the CM daemon to grab the lock for a moment,
so lets not fail. Rare case.
parent 00e28c5c
......@@ -506,7 +506,7 @@ sub CreateSliver($)
#
# Leave the slice intact on error, so we can go look at it.
#
if ($slice->Lock() != 0) {
if ($slice->WaitForLock(30) != 0) {
print STDERR "CreateSliver: Could not lock $slice before start\n";
return GeniResponse->Create(GENIRESPONSE_ERROR, undef,
"Internal Error");
......
......@@ -478,6 +478,26 @@ sub UnLock($)
return 0;
}
#
# Wait for lock with timeout (in seconds).
#
sub WaitForLock($$)
{
my ($self, $timeout) = @_;
return $self->Lock()
if (! $timeout);
while ($timeout >= 0) {
return 0
if ($self->Lock() == 0);
$timeout--;
sleep(1);
}
return -1;
}
#
# The stitching lock is used solely for controlling concurrency related
# to stitching.
......
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