]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
BackoffThrottle: use wait_for instead of wait_until
authorSamuel Just <sjust@redhat.com>
Wed, 18 May 2016 18:49:19 +0000 (11:49 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 23 May 2016 17:37:14 +0000 (10:37 -0700)
On some platforms, wait_until won't surrender the lock
with a negative argument.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/common/Throttle.cc

index 3b909ee4112478c73363c2332e1568cc46d8753c..14cf1ba894d91ee2d0d0d48361ea1c86cc4fc62f 100644 (file)
@@ -376,11 +376,11 @@ std::chrono::duration<double> BackoffThrottle::get(uint64_t c)
 
   auto start = std::chrono::system_clock::now();
   delay = _get_delay(c);
-  while (((start + delay) > std::chrono::system_clock::now()) ||
+  while ((delay > std::chrono::duration<double>(0)) ||
         !((max == 0) || (current == 0) || ((current + c) <= max))) {
     assert(ticket == waiters.begin());
-    (*ticket)->wait_until(l, start + delay);
-    delay = _get_delay(c);
+    (*ticket)->wait_for(l, delay);
+    delay = _get_delay(c) - (std::chrono::system_clock::now() - start);
   }
   waiters.pop_front();
   _kick_waiters();