From: Joao Eduardo Luis Date: Mon, 17 Jul 2017 14:41:49 +0000 (+0100) Subject: mon/LogMonitor: don't read list's end() for log last X-Git-Tag: v12.1.2~221^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=67998dbeae8fa1046bf282ce4bd2b55229648fdf;p=ceph.git mon/LogMonitor: don't read list's end() for log last 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 --- diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 20fc1332763a..c7c2b281b48c 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -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;