Commit e11578a7 authored by Leigh Stoller's avatar Leigh Stoller

Add TakeLock() to pass lock from script to script.

parent 242e972c
......@@ -2122,6 +2122,32 @@ sub Unlock($)
return 0;
}
#
# Steal the lock
#
sub TakeLock($)
{
my ($self) = @_;
return -1
if (!DBQueryWarn("lock tables images write"));
my $imageid = $self->imageid();
my $query_result =
DBQueryWarn("update images set locker_pid=$PID " .
"where imageid='$imageid' and locked is not null");
if (! $query_result ||
$query_result->numrows == 0) {
DBQueryWarn("unlock tables");
return -1;
}
DBQueryWarn("unlock tables");
$self->{'IMAGE'}->{'locker_pid'} = $PID;
return 0;
}
sub GotLock($)
{
my ($self) = @_;
......
......@@ -818,6 +818,13 @@ sub GotLock($)
return $self->image()->GotLock();
}
sub TakeLock($)
{
my ($self) = @_;
return $self->image()->TakeLock();
}
#
# Wait to get lock.
#
......
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