From 67998dbeae8fa1046bf282ce4bd2b55229648fdf Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Mon, 17 Jul 2017 15:41:49 +0100 Subject: [PATCH] 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 --- src/mon/LogMonitor.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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; -- 2.47.3