]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/Throttle: maintain count even if disabled
authorSamuel Just <sjust@redhat.com>
Tue, 4 Jun 2019 23:48:12 +0000 (16:48 -0700)
committerSamuel Just <sjust@redhat.com>
Fri, 27 Sep 2019 22:55:18 +0000 (15:55 -0700)
Otherwise, it will behave incorrectly if enabled dynamically.

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

index 50a835ee5f19385903af3df6e8b8b4502c55d4a3..69d0f1086b0107c785c30d32c1916715a7757a32 100644 (file)
@@ -151,6 +151,7 @@ int64_t Throttle::take(int64_t c)
 bool Throttle::get(int64_t c, int64_t m)
 {
   if (0 == max && 0 == m) {
+    count += c;
     return false;
   }
 
@@ -183,6 +184,7 @@ bool Throttle::get(int64_t c, int64_t m)
 bool Throttle::get_or_fail(int64_t c)
 {
   if (0 == max) {
+    count += c;
     return true;
   }
 
@@ -211,6 +213,7 @@ bool Throttle::get_or_fail(int64_t c)
 int64_t Throttle::put(int64_t c)
 {
   if (0 == max) {
+    count -= c;
     return 0;
   }