diff options
author | Thomas Steur <tsteur@users.noreply.github.com> | 2019-12-30 20:54:09 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-30 20:54:09 +0300 |
commit | 520ba4881ab9d3e30c3d16da9e32a74633e6653c (patch) | |
tree | 8635a14dd2b648a6fd03e81f0fbe2735d4c64153 /core/Concurrency | |
parent | 4754e0e0d68d1fa55cbde06d3980d3bf1137e07f (diff) |
Revert prevent race condition in plugin settings #15249 (#15325)
Diffstat (limited to 'core/Concurrency')
-rw-r--r-- | core/Concurrency/Lock.php | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/core/Concurrency/Lock.php b/core/Concurrency/Lock.php index f63bec640a..5136fccbf3 100644 --- a/core/Concurrency/Lock.php +++ b/core/Concurrency/Lock.php @@ -12,8 +12,6 @@ use Piwik\Common; class Lock { - const MAX_KEY_LEN = 70; - /** * @var LockBackend */ @@ -48,30 +46,6 @@ class Lock return $this->backend->getKeysMatchingPattern($this->lockKeyStart . '*'); } - public function execute($id, $callback) - { - if (Common::mb_strlen($id) > self::MAX_KEY_LEN) { - // Lock key might be too long for DB column, so we hash it but leave the start of the original as well - // to make it more readable - $md5Len = 32; - $id = Common::mb_substr($id, 0, self::MAX_KEY_LEN - $md5Len - 1) . md5($id); - } - - $i = 0; - while (!$this->acquireLock($id)) { - $i++; - usleep( 100 * 1000 ); // 100ms - if ($i > 50) { // give up after 5seconds (50 * 100ms) - throw new \Exception('Could not get the lock for ID: ' . $id); - } - }; - try { - return $callback(); - } finally { - $this->unlock(); - } - } - public function acquireLock($id, $ttlInSeconds = 60) { $this->lockKey = $this->lockKeyStart . $id; |