Commit 18c04f49 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Add an up/down lock to use from the mapper, to limit the number

of concurrent mappers that can run at once. Currently used only
on the Geni path.
parent d02a9846
......@@ -285,4 +285,32 @@ sub EmulabUnlock($)
return 0;
}
#
# Count up/down locking.
#
sub EmulabCountLock($$)
{
my ($name, $count) = @_;
my $query_result =
DBQueryWarn("update emulab_locks set value=value+1 " .
"where name='$name' and value<${count}");
if (! $query_result || $query_result->affectedrows == 0) {
return -1;
}
return 0;
}
sub EmulabCountUnlock($)
{
my ($name) = @_;
DBQueryWarn("update emulab_locks set value=value-1 ".
"where name='$name' and value>0");
or return -1;
return 0;
}
1;
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