]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: MonitorDBStore: get_next_key() only if prefix matches 4783/head
authorJoao Eduardo Luis <joao@suse.de>
Wed, 27 May 2015 21:28:49 +0000 (22:28 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Thu, 28 May 2015 07:12:48 +0000 (08:12 +0100)
get_next_key() had a bug in which we would always return the first key
from the iterator, regardless of whether its prefix had been specified
to the iterator.

Fixes: #11786
Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/mon/MonitorDBStore.h

index d00d3607960b0a408c1a37f18ce21cee78e9bf62..9feb266c49ee8783a66505e39c2102d72deb74eb 100644 (file)
@@ -448,11 +448,13 @@ class MonitorDBStore
 
     virtual pair<string,string> get_next_key() {
       assert(iter->valid());
-      pair<string,string> r = iter->raw_key();
-      do {
-       iter->next();
-      } while (iter->valid() && sync_prefixes.count(iter->raw_key().first) == 0);
-      return r;
+
+      for (; iter->valid(); iter->next()) {
+        pair<string,string> r = iter->raw_key();
+        if (sync_prefixes.count(r.first) > 0)
+          return r;
+      }
+      return pair<string,string>();
     }
 
     virtual bool _is_valid() {