From 16df7715b96b436ac3133a92830b37a2673633de Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 12 Jun 2017 15:42:54 +0000 Subject: [PATCH] Avoid locking problems in lock class --- src/Util/Lock.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Util/Lock.php b/src/Util/Lock.php index b2c5afc662..6d7952ffa9 100644 --- a/src/Util/Lock.php +++ b/src/Util/Lock.php @@ -61,6 +61,8 @@ class Lock { $cachekey = get_app()->get_hostname().";lock:".$fn_name; do { + // We only lock to be sure that nothing happens at exactly the same time + dba::lock('locks'); $lock = $memcache->get($cachekey); if (!is_bool($lock)) { @@ -76,6 +78,9 @@ class Lock { $memcache->set($cachekey, getmypid(), MEMCACHE_COMPRESSED, 300); $got_lock = true; } + + dba::unlock(); + if (!$got_lock && ($timeout > 0)) { usleep($wait_sec * 1000000); }