mirror of
https://github.com/friendica/friendica
synced 2025-05-02 17:04:24 +02:00
Fixing force-flag for lock-releasing
This commit is contained in:
parent
9f11476ca0
commit
9b07132b80
6 changed files with 23 additions and 11 deletions
|
@ -61,11 +61,15 @@ class CacheLockDriver extends AbstractLockDriver
|
|||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function releaseLock($key)
|
||||
public function releaseLock($key, $force = false)
|
||||
{
|
||||
$cachekey = self::getLockKey($key);
|
||||
|
||||
$this->cache->compareDelete($cachekey, getmypid());
|
||||
if ($force) {
|
||||
$this->cache->delete($key);
|
||||
} else {
|
||||
$this->cache->compareDelete($cachekey, getmypid());
|
||||
}
|
||||
$this->markRelease($key);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,9 +68,15 @@ class DatabaseLockDriver extends AbstractLockDriver
|
|||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function releaseLock($key)
|
||||
public function releaseLock($key, $force = false)
|
||||
{
|
||||
DBA::delete('locks', ['name' => $key, 'pid' => $this->pid]);
|
||||
if ($force) {
|
||||
$where = ['name' => $key];
|
||||
} else {
|
||||
$where = ['name' => $key, 'pid' => $this->pid];
|
||||
}
|
||||
|
||||
DBA::delete('locks', $where);
|
||||
|
||||
$this->markRelease($key);
|
||||
|
||||
|
|
|
@ -33,11 +33,12 @@ interface ILockDriver
|
|||
/**
|
||||
* Releases a lock if it was set by us
|
||||
*
|
||||
* @param string $key The Name of the lock
|
||||
* @param string $key The Name of the lock
|
||||
* @param bool $force Force the lock to get released
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function releaseLock($key);
|
||||
public function releaseLock($key, $force = false);
|
||||
|
||||
/**
|
||||
* Releases all lock that were set by us
|
||||
|
|
|
@ -50,7 +50,7 @@ class SemaphoreLockDriver extends AbstractLockDriver
|
|||
/**
|
||||
* (@inheritdoc)
|
||||
*/
|
||||
public function releaseLock($key)
|
||||
public function releaseLock($key, $force = false)
|
||||
{
|
||||
if (empty(self::$semaphore[$key])) {
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue