]> git.mxchange.org Git - friendica.git/commitdiff
Avoid locking problems in lock class
authorMichael <heluecht@pirati.ca>
Mon, 12 Jun 2017 15:42:54 +0000 (15:42 +0000)
committerMichael <heluecht@pirati.ca>
Mon, 12 Jun 2017 15:42:54 +0000 (15:42 +0000)
src/Util/Lock.php

index b2c5afc662acf65caeb5fd3d23e2a807b0cf15d2..6d7952ffa914524b0a40f738af91a3ceccf2a3df 100644 (file)
@@ -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);
                                }