]> git.mxchange.org Git - friendica.git/commitdiff
Only wait when you have a timout value at all
authorMichael <heluecht@pirati.ca>
Tue, 6 Jun 2017 04:22:18 +0000 (04:22 +0000)
committerMichael <heluecht@pirati.ca>
Tue, 6 Jun 2017 04:22:18 +0000 (04:22 +0000)
src/Util/Lock.php

index 63f9b5f9730b63f36134764b10cfcec83cb7f52b..af15e106d56545a4c976976e609382bc85de93d8 100644 (file)
@@ -76,7 +76,7 @@ class Lock {
                                        $memcache->set($cachekey, getmypid(), MEMCACHE_COMPRESSED, 300);
                                        $got_lock = true;
                                }
-                               if (!$got_lock) {
+                               if (!$got_lock AND ($timeout > 0)) {
                                        usleep($wait_sec * 1000000);
                                }
                        } while (!$got_lock AND ((time() - $start) < $timeout));
@@ -112,7 +112,7 @@ class Lock {
 
                        dba::unlock();
 
-                       if (!$got_lock) {
+                       if (!$got_lock AND ($timeout > 0)) {
                                sleep($wait_sec);
                        }
                } while (!$got_lock AND ((time() - $start) < $timeout));