]> git.pond.sub.org Git - empserver/commitdiff
news: Merge news more aggressively
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 27 Jun 2016 19:35:23 +0000 (21:35 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sun, 6 Aug 2017 18:09:17 +0000 (20:09 +0200)
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 <armbru@pond.sub.org>
src/lib/subs/nreport.c

index 1df7cbde24a4eff4be2862341f7ef43089bad944..63457b979bf35bf06cf588f7e9e7d3c7056bcf4d 100644 (file)
@@ -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;
        }