/** * Will release a lock with the given name, * if it has been acquired before */ public function release() { if ($this->counter > 1) { // this is a lock that we acquired multiple times: // simply decrease counter $this->counter -= 1; //error_log('released ' . getmypid() . "[{$this->counter}]"); } elseif ($this->counter == 1) { // simply release the lock $this->counter = 0; $this->lock->release(); self::$_acquired_lock = NULL; //error_log('released ' . getmypid()); } else { // lock has already been released! error_log("org.project60.sepa: This process cannot realease lock '{$name}', it has already been released before."); throw new Exception("This process cannot realease lock '{$name}', it has already been released before."); } }
/** * Get a batching lock * * the lock is needed so that only one relevant process can access the * SEPA data structures at a time * * @return CRM_Utils_SepaSafeLock object, or NULL if acquisition timed out */ static function getLock() { $timeout = CRM_Sepa_Logic_Settings::getSetting('batching.UPDATE.lock.timeout'); return CRM_Utils_SepaSafeLock::acquireLock('org.project60.sepa.batching.update', $timeout); }