]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
BackoffThrottle: wait() if past max 9235/head
authorSamuel Just <sjust@redhat.com>
Wed, 18 May 2016 19:09:10 +0000 (12:09 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 23 May 2016 17:37:15 +0000 (10:37 -0700)
Otherwise, we risk spinning on wait_for() with a small
delay.

Fixes: http://tracker.ceph.com/issues/15953
Signed-off-by: Samuel Just <sjust@redhat.com>
src/common/Throttle.cc

index 14cf1ba894d91ee2d0d0d48361ea1c86cc4fc62f..8a52906cd5e5de436ac1470eb80e4f877be4c248 100644 (file)
@@ -376,10 +376,15 @@ std::chrono::duration<double> BackoffThrottle::get(uint64_t c)
 
   auto start = std::chrono::system_clock::now();
   delay = _get_delay(c);
-  while ((delay > std::chrono::duration<double>(0)) ||
-        !((max == 0) || (current == 0) || ((current + c) <= max))) {
+  while (true) {
+    if (!((max == 0) || (current == 0) || (current + c) <= max)) {
+      (*ticket)->wait(l);
+    } else if (delay > std::chrono::duration<double>(0)) {
+      (*ticket)->wait_for(l, delay);
+    } else {
+      break;
+    }
     assert(ticket == waiters.begin());
-    (*ticket)->wait_for(l, delay);
     delay = _get_delay(c) - (std::chrono::system_clock::now() - start);
   }
   waiters.pop_front();