From cbc23ae85832b82618e8c0d198a0b053169b303a Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 27 Jun 2016 21:35:23 +0200 Subject: [PATCH] news: Merge news more aggressively News reporting merges news items into recent items with same actor, action and victim, as long as the merged number of times doesn't exceed 65535 (127 before the previous commit). This complicates incremental xdump a bit: when the client sees a row, it's not obvious which of the previously dumped rows it replaces. Actually, rows with the same actor, action, victim and time replace in xdump order. Merge news item regardless of the number of times; saturate the number at 65535. Now the replacement is obvious, because there can only be one news item with the same actor, action, victim and time. This also rate-limits floods of identical news should they happen for some reason. Signed-off-by: Markus Armbruster --- src/lib/subs/nreport.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/subs/nreport.c b/src/lib/subs/nreport.c index 1df7cbde..63457b97 100644 --- a/src/lib/subs/nreport.c +++ b/src/lib/subs/nreport.c @@ -168,9 +168,9 @@ ncache(int actor, int event, int victim, int times) dur = now - np->news.nws_when; if (dur > minutes(5)) continue; - if (np->news.nws_vrb == event && np->news.nws_vno == victim && - np->news.nws_ntm + times <= 65535) { - np->news.nws_ntm += times; + if (np->news.nws_vrb == event && np->news.nws_vno == victim) { + np->news.nws_ntm = LIMIT_TO(np->news.nws_ntm + times, + 0, 65535); np->news.nws_duration = dur; return np; }