From: Joao Eduardo Luis Date: Wed, 27 May 2015 21:28:49 +0000 (+0100) Subject: mon: MonitorDBStore: get_next_key() only if prefix matches X-Git-Tag: v0.80.11~23^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d52187019d321fe8a2dc54fe8a67a5139c310db1;p=ceph.git mon: MonitorDBStore: get_next_key() only if prefix matches 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 (cherry picked from commit 2cc7aee1abe40453093306c8fef2312b650dff5d) --- diff --git a/src/mon/MonitorDBStore.h b/src/mon/MonitorDBStore.h index 1576db77d3c..ff97878947c 100644 --- a/src/mon/MonitorDBStore.h +++ b/src/mon/MonitorDBStore.h @@ -390,11 +390,13 @@ class MonitorDBStore virtual pair get_next_key() { assert(iter->valid()); - pair 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 r = iter->raw_key(); + if (sync_prefixes.count(r.first) > 0) + return r; + } + return pair(); } virtual bool _is_valid() {