From fb7022c54d0da4773e437139c0cdb595fe83027d Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 21 Oct 2015 20:14:54 -0700 Subject: [PATCH] Bound BagOStuff::lock() RTT estimate for sanity The timestamp difference might be 0 (or in rare cases, less) Change-Id: I0298b413df637d9da5ff33c078ad49dadc8a46ce --- includes/libs/objectcache/BagOStuff.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index 5dfec6ef72..c3c357ffa5 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -328,7 +328,8 @@ abstract class BagOStuff implements LoggerAwareInterface { } elseif ( $this->getLastError() || $timeout <= 0 ) { $locked = false; // network partition or non-blocking } else { - $uRTT = ceil( 1e6 * ( microtime( true ) - $timestamp ) ); // estimate RTT (us) + // Estimate the RTT (us); use 1ms minimum for sanity + $uRTT = max( 1e3, ceil( 1e6 * ( microtime( true ) - $timestamp ) ) ); $sleep = 2 * $uRTT; // rough time to do get()+set() $attempts = 0; // failed attempts -- 2.20.1