1
0
forked from bip/bip

Add track_backlog member in lfg, so we have a cleaner way to exempt a channel from backloggin.

This commit is contained in:
Arnaud Cornet 2007-11-25 15:29:32 +01:00
parent cc9afd6b1e
commit b3b6df53bb
3 changed files with 29 additions and 17 deletions

View File

@ -489,12 +489,12 @@ static int add_connection(bip_t *bip, struct user *user, list_t *data)
ci = hash_get(&l->chan_infos, name); ci = hash_get(&l->chan_infos, name);
if (!ci) { if (!ci) {
ci = calloc(sizeof(struct chan_info), 1); ci = chan_info_new();
hash_insert(&l->chan_infos, name, ci); hash_insert(&l->chan_infos, name, ci);
/* FIXME: this order is not reloaded */ /* FIXME: this order is not reloaded */
list_add_last(&l->chan_infos_order, ci); list_add_last(&l->chan_infos_order, ci);
ci->backlog = 1;
} }
ci->backlog = 1;
while ((t2 = list_remove_first(t->pdata))) { while ((t2 = list_remove_first(t->pdata))) {
switch (t2->type) { switch (t2->type) {

View File

@ -288,6 +288,7 @@ logfilegroup_t *log_find_file(log_t *logdata, char *destination)
char *filename = NULL; char *filename = NULL;
time_t t; time_t t;
struct tm *ltime; struct tm *ltime;
struct link *l;
if (!ischannel(*destination)) if (!ischannel(*destination))
destination = "privates"; destination = "privates";
@ -312,6 +313,24 @@ logfilegroup_t *log_find_file(log_t *logdata, char *destination)
lfg = hash_get(&logdata->logfgs, destination); lfg = hash_get(&logdata->logfgs, destination);
if (!lfg) if (!lfg)
fatal("internal log_find_file"); 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) if (filename)
free(filename); free(filename);
return lfg; return lfg;
@ -641,7 +660,10 @@ void log_client_connected(log_t *logdata)
void log_advance_backlogs(log_t* ld, logfilegroup_t *lfg) void log_advance_backlogs(log_t* ld, logfilegroup_t *lfg)
{ {
int c; int c;
(void)ld;
if (!lfg->track_backlog)
return;
if (!ld->user->backlog || ld->user->backlog_lines == 0) if (!ld->user->backlog || ld->user->backlog_lines == 0)
return; return;
@ -742,20 +764,6 @@ char *log_beautify(log_t *logdata, char *buf, char *dest)
lots = p - sots; lots = p - sots;
p++; 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 (strncmp(p, "-!-", 3) == 0) {
if (logdata->user->bl_msg_only) if (logdata->user->bl_msg_only)
return NULL; return NULL;
@ -907,6 +915,9 @@ char *log_backread(log_t *logdata, char *destination, int *skip)
if (!lfg) if (!lfg)
return NULL; return NULL;
if (!lfg->track_backlog)
return NULL;
if (!logdata->backlogging) { if (!logdata->backlogging) {
logdata->backlogging = 1; logdata->backlogging = 1;
mylog(LOG_DEBUG, "backlogging!"); mylog(LOG_DEBUG, "backlogging!");

View File

@ -46,6 +46,7 @@ typedef struct logfilegroup
list_t *memlog; list_t *memlog;
int memc; int memc;
list_iterator_t backlog_it; list_iterator_t backlog_it;
int track_backlog;
} logfilegroup_t; } logfilegroup_t;
typedef struct log { typedef struct log {