Commit bd9cdb82 authored by mikeytown2's avatar mikeytown2

Issue #2268617 by mikeytown2: Allow for 3rd part modules to acquire a headless lock.

parent c69a822d
......@@ -2264,7 +2264,6 @@ function httprl_queue_background_callback(&$args, &$result = NULL) {
return httprl_request($url, $options);
}
/**
* Get a lock so background calls work.
*
......@@ -2288,13 +2287,27 @@ function httprl_acquire_lock(&$result) {
$times[] = $result->options['global_timeout'];
}
$time = max($times);
$name = $result->options['lock_name'];
return httprl_acquire_headless_lock($name, $time);
}
/**
* Get a floating lock so background calls work.
*
* @param string $name
* Name of the lock to use.
* @param int $time
* How long the lock will last.
*/
function httprl_acquire_headless_lock($name, $time = 60) {
// Acquire lock for this run.
$locked = FALSE;
$lock_counter = 0;
$name = $result->options['lock_name'];
while (!$locked && $lock_counter < 3) {
// Set lock to maximum amount of time.
$locked = lock_acquire($name, max($times));
$locked = lock_acquire($name, $time);
$lock_counter++;
}
if (!$locked) {
......
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