From e546de81cbecac2b02d29a02d6c6fd7d0785d739 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Sat, 14 Sep 2019 13:11:20 +0100 Subject: Handle ignoring replay messages from before we launched better to avoid misleading error messages going to clients. --- replay.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'replay.c') diff --git a/replay.c b/replay.c index 7100116..6e7370f 100644 --- a/replay.c +++ b/replay.c @@ -221,7 +221,7 @@ int replaylines(int seconds, char *basedir) { // seconds ago, plus however many lines 'linenum' is set to. // Also modify the line to include a timestamp in the form "[HH:MM:SS]", or [DD/MM/YY HH:MM:SS] // if settings.replaydates == 1. -// Returns 1 on success, or 0 on failure. +// Returns 1 on success, 0 on failure, or -1 if the line should be ignored. // TODO - This is horribly inefficient since it re-reads the entire file each call, rewrite this! int readreplayline(int seconds, int linenum, char *str, struct settings *settings, struct ircdstate *ircdstate) { FILE *fp; @@ -257,17 +257,18 @@ int readreplayline(int seconds, int linenum, char *str, struct settings *setting // If the line is within range of the requested time... if (timestamp >= timenow - seconds) { - // ...and it wasn't before blabouncer launched... - if (timestamp <= ircdstate->launchtime) { - // Don't replay if this replay line happened before blabouncer launched, - // to avoid weird synchronisation issues with uncertain events from before - // we launched. - debugprint(DEBUG_FULL, "readreplayline(): Ignoring line '%s' from before we launched.\n", line); - continue; - } - - // ...and it is the current requested line then return it + // ...and it is the current requested line... if (count == linenum) { + // ...and it wasn't before blabouncer launched... + if (timestamp < ircdstate->launchtime) { + // Don't replay if this replay line happened before blabouncer launched, + // to avoid weird synchronisation issues with uncertain events from before + // we launched. + debugprint(DEBUG_FULL, "readreplayline(): Ignoring line '%s' from before we launched.\n", line); + fclose(fp); + return -1; + } + // ...then return it // Insert our formatted [HH:MM:SS] timestamp into the message formattime(line, settings->replaydates); -- cgit v1.2.3