Only wait when you have a timout value at all

This commit is contained in:
Michael 2017-06-06 04:22:18 +00:00
parent ba7b4fddea
commit 5dfa513b62
1 changed files with 2 additions and 2 deletions

View File

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