]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/LogMonitor: don't read list's end() for log last 16376/head
authorJoao Eduardo Luis <joao@suse.de>
Mon, 17 Jul 2017 14:41:49 +0000 (15:41 +0100)
committerJoao Eduardo Luis <joao@suse.de>
Mon, 17 Jul 2017 14:41:49 +0000 (15:41 +0100)
We will assert semi-randomly if we read the end of the list, which is
not a real element. Instead, walk the list in reverse.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
src/mon/LogMonitor.cc

index 20fc1332763a37bd34577011010a12e82b765c34..c7c2b281b48ced94585fe2c98f6f86b579bcd97c 100644 (file)
@@ -428,14 +428,15 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op)
       return entry.prio >= level && (entry.channel == channel || channel == "*");
     };
 
-    auto p = summary.tail.end();
-    while (num > 0 && p != summary.tail.begin()) {
-      if (match(*p)) {
+    auto rp = summary.tail.rbegin();
+    while (num > 0 && rp != summary.tail.rend()) {
+      if (match(*rp)) {
         num--;
       }
-      --p;
+      ++rp;
     }
     ostringstream ss;
+    auto p = summary.tail.begin();
     for ( ; p != summary.tail.end(); ++p) {
       if (!match(*p)) {
         continue;