From: Sage Weil Date: Mon, 3 Jun 2013 01:07:34 +0000 (-0700) Subject: os/LevelDBStore: fix merge loop X-Git-Tag: v0.64~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eb6d5fcf994d2a25304827d7384eee58f40939af;p=ceph.git os/LevelDBStore: fix merge loop We were double-incrementing p, both in the for statement and in the body. While we are here, drop the unnecessary else's. Signed-off-by: Sage Weil --- diff --git a/src/os/LevelDBStore.cc b/src/os/LevelDBStore.cc index 4e4e0e5c1777..0b1ea5c19134 100644 --- a/src/os/LevelDBStore.cc +++ b/src/os/LevelDBStore.cc @@ -229,26 +229,27 @@ void LevelDBStore::compact_range_async(const string& start, const string& end) // try to merge adjacent ranges. this is O(n), but the queue should // be short. note that we do not cover all overlap cases and merge // opportunities here, but we capture the ones we currently need. - list< pair >::iterator p; - for (p = compact_queue.begin(); p != compact_queue.end(); ++p) { + list< pair >::iterator p = compact_queue.begin(); + while (p != compact_queue.end()) { if (p->first == start && p->second == end) { // dup; no-op return; - } else if (p->first <= end && p->first > start) { + } + if (p->first <= end && p->first > start) { // merge with existing range to the right compact_queue.push_back(make_pair(start, p->second)); compact_queue.erase(p); logger->inc(l_leveldb_compact_queue_merge); break; - } else if (p->second >= start && p->second < end) { + } + if (p->second >= start && p->second < end) { // merge with existing range to the left compact_queue.push_back(make_pair(p->first, end)); compact_queue.erase(p); logger->inc(l_leveldb_compact_queue_merge); break; - } else { - ++p; } + ++p; } if (p == compact_queue.end()) { // no merge, new entry.