From b3b6df53bb47d9626dd62f69dd4cca206124615a Mon Sep 17 00:00:00 2001 From: Arnaud Cornet Date: Sun, 25 Nov 2007 15:29:32 +0100 Subject: [PATCH] Add track_backlog member in lfg, so we have a cleaner way to exempt a channel from backloggin. --- src/bip.c | 4 ++-- src/log.c | 41 ++++++++++++++++++++++++++--------------- src/log.h | 1 + 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/bip.c b/src/bip.c index 02150b9..19ee35a 100644 --- a/src/bip.c +++ b/src/bip.c @@ -489,12 +489,12 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data) ci = hash_get(&l->chan_infos, name); if (!ci) { - ci = calloc(sizeof(struct chan_info), 1); + ci = chan_info_new(); hash_insert(&l->chan_infos, name, ci); /* FIXME: this order is not reloaded */ list_add_last(&l->chan_infos_order, ci); + ci->backlog = 1; } - ci->backlog = 1; while ((t2 = list_remove_first(t->pdata))) { switch (t2->type) { diff --git a/src/log.c b/src/log.c index d8047e8..266d9a6 100644 --- a/src/log.c +++ b/src/log.c @@ -288,6 +288,7 @@ logfilegroup_t *log_find_file(log_t *logdata, char *destination) char *filename = NULL; time_t t; struct tm *ltime; + struct link *l; if (!ischannel(*destination)) destination = "privates"; @@ -312,6 +313,24 @@ logfilegroup_t *log_find_file(log_t *logdata, char *destination) lfg = hash_get(&logdata->logfgs, destination); if (!lfg) fatal("internal log_find_file"); + /* ok we are allocating a new lfg now, let's set it up for + * backlogging if applicable */ + if (!logdata->user) + fatal("log_find_file: no user associated to logdata"); + if (!logdata->network) + fatal("log_find_file: no network id associated to " + "logdata"); + l = hash_get(&logdata->user->connections, logdata->network); + if (!l) + fatal("log_beautify: no connection associated to " + "logdata"); + struct chan_info *ci = hash_get(&l->chan_infos, destination); + if (ci && !ci->backlog) { + lfg->track_backlog = 0; + } else { + lfg->track_backlog = 1; + } + if (filename) free(filename); return lfg; @@ -641,7 +660,10 @@ void log_client_connected(log_t *logdata) void log_advance_backlogs(log_t* ld, logfilegroup_t *lfg) { int c; - (void)ld; + + if (!lfg->track_backlog) + return; + if (!ld->user->backlog || ld->user->backlog_lines == 0) return; @@ -742,20 +764,6 @@ char *log_beautify(log_t *logdata, char *buf, char *dest) lots = p - sots; p++; - if (!logdata->user) - fatal("log_beautify: no user associated to logdata"); - if (!logdata->network) - fatal("log_beautify: no network id associated to logdata"); - l = hash_get(&logdata->user->connections, logdata->network); - if (!l) - fatal("log_beautify: no connection associated to logdata"); - ci = hash_get(&l->chan_infos, dest); - if (ci && !ci->backlog) { - mylog(LOG_DEBUG, "Skipping unwanted channel %s for backlog", - dest); - return NULL; - } - if (strncmp(p, "-!-", 3) == 0) { if (logdata->user->bl_msg_only) return NULL; @@ -907,6 +915,9 @@ char *log_backread(log_t *logdata, char *destination, int *skip) if (!lfg) return NULL; + if (!lfg->track_backlog) + return NULL; + if (!logdata->backlogging) { logdata->backlogging = 1; mylog(LOG_DEBUG, "backlogging!"); diff --git a/src/log.h b/src/log.h index dc4adaa..9dafd54 100644 --- a/src/log.h +++ b/src/log.h @@ -46,6 +46,7 @@ typedef struct logfilegroup list_t *memlog; int memc; list_iterator_t backlog_it; + int track_backlog; } logfilegroup_t; typedef struct log {