function lock_acquire


Error message

User warning: The following module is missing from the file system: theme/theme. For information about how to fix this, see the documentation page. in _drupal_trigger_error_with_delayed_logging() (line 1156 of /var/www/html/elmsln_community/
cis7 lock_acquire($name, $timeout = 30.0)
cle7 lock_acquire($name, $timeout = 30.0)
elmsmedia7 lock_acquire($name, $timeout = 30.0)
icor7 lock_acquire($name, $timeout = 30.0)
meedjum_blog7 lock_acquire($name, $timeout = 30.0)
mooc7 lock_acquire($name, $timeout = 30.0)

Acquire (or renew) a lock, but do not block if it fails.


$name: The name of the lock.

$timeout: A number of seconds (float) before the lock expires (minimum of 0.001).

Return value

TRUE if the lock was acquired, FALSE if it failed.

Related topics

21 calls to lock_acquire()
advagg_build_aggregates in sites/all/modules/ulmus/advagg/advagg.module
Builds the requested CSS/JS aggregates.
advagg_get_current_hooks_hash in sites/all/modules/ulmus/advagg/advagg.module
Get the hash of all hooks & settings that affect aggregated files contents.
advagg_insert_update_db in sites/all/modules/ulmus/advagg/
Insert/Update data in advagg_files, advagg_aggregates, & advagg_aggregates_versions tables.
advagg_missing_generate in sites/all/modules/ulmus/advagg/
Generates a missing CSS/JS file and send it to client.
advagg_update_atime in sites/all/modules/ulmus/advagg/advagg.module
Update the atime value in the advagg_aggregates_versions table.

... See full list


includes/, line 102
A database-mediated implementation of a locking mechanism.


function lock_acquire($name, $timeout = 30.0) {
  global $locks;

  // Insure that the timeout is at least 1 ms.
  $timeout = max($timeout, 0.001);
  $expire = microtime(TRUE) + $timeout;
  if (isset($locks[$name])) {
    // Try to extend the expiration of a lock we already acquired.
    $success = (bool) db_update('semaphore')->fields(array('expire' => $expire))->condition('name', $name)->condition('value', _lock_id())->execute();
    if (!$success) {
      // The lock was broken.
    return $success;
  else {
    // Optimistically try to acquire the lock, then retry once if it fails.
    // The first time through the loop cannot be a retry.
    $retry = FALSE;
    // We always want to do this code at least once.
    do {
      try {
          'name' => $name,
          'value' => _lock_id(),
          'expire' => $expire,
        // We track all acquired locks in the global variable.
        $locks[$name] = TRUE;
        // We never need to try again.
        $retry = FALSE;
      catch (PDOException $e) {
        // Suppress the error. If this is our first pass through the loop,
        // then $retry is FALSE. In this case, the insert must have failed
        // meaning some other request acquired the lock but did not release it.
        // We decide whether to retry by checking lock_may_be_available()
        // Since this will break the lock in case it is expired.
        $retry = $retry ? FALSE : lock_may_be_available($name);
      // We only retry in case the first attempt failed, but we then broke
      // an expired lock.
    } while ($retry);
  return isset($locks[$name]);



Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/ in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/
The website encountered an unexpected error. Please try again later.