From: Ian Jackson Date: Sat, 29 May 2010 13:34:08 +0000 (+0100) Subject: Accumulate backlog counts rather than reporting every file X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=innduct.git;a=commitdiff_plain;h=c2ec61d4f426a04f288559c5ad50df822b7dcfb8 Accumulate backlog counts rather than reporting every file --- diff --git a/innduct.h b/innduct.h index d6dc8dd..fc04d8a 100644 --- a/innduct.h +++ b/innduct.h @@ -497,6 +497,8 @@ extern int until_stats_log; extern StateMachineState sms; extern int until_flush; extern InputFile *main_input_file, *flushing_input_file, *backlog_input_file; +extern Counts backlog_counts; +extern int backlog_counts_report; extern FILE *defer; extern int until_connect, until_backlog_nextscan; extern double accept_proportion; diff --git a/statemc.c b/statemc.c index 172bbe8..78912e7 100644 --- a/statemc.c +++ b/statemc.c @@ -31,6 +31,8 @@ StateMachineState sms; int until_flush; InputFile *main_input_file, *flushing_input_file, *backlog_input_file; +Counts backlog_counts; +int backlog_counts_report; FILE *defer; /* initialisation to 0 is good */ @@ -216,9 +218,8 @@ static int inputfile_is_done(InputFile *ipf) { return 1; } -static void notice_processed(InputFile *ipf, int completed, - const char *what, const char *spec) { - if (!ipf) return; /* allows preterminate to be lazy */ +static void notice_processed_counts(Counts *counts, int completed, + InputFile *ipf, const char *what) { #define RCI_NOTHING(x) /* nothing */ #define RCI_TRIPLE_FMT(x) " " #x "=" RCI_TRIPLE_FMT_BASE @@ -229,15 +230,15 @@ static void notice_processed(InputFile *ipf, int completed, char *inprog= completed ? xasprintf("%s","") /* GCC produces a stupid warning for printf("") ! */ : xasprintf(" inprogress=%ld", ipf->inprogress); - char *autodefer= ipf->autodefer >= 0 + char *autodefer= ipf && ipf->autodefer >= 0 ? xasprintf(" autodeferred=%ld", ipf->autodefer) : xasprintf("%s",""); - info("%s %s%s read=%d (+bl=%d,+err=%d)%s%s" + info("%s %s read=%d (+bl=%d,+err=%d)%s%s" " missing=%d offered=%d (ch=%d,nc=%d) accepted=%d (ch=%d,nc=%d)" RESULT_COUNTS(RCI_NOTHING, RCI_TRIPLE_FMT) , - completed?"completed":"processed", what, spec, + completed?"completed":"processed", what, ipf->counts.events[read_ok], ipf->counts.events[read_blank], ipf->counts.events[read_err], inprog, autodefer, ipf->counts.events[nooffer_missing], @@ -256,17 +257,32 @@ static void notice_processed(InputFile *ipf, int completed, #undef CNT } +static void notice_processed_inputfile(InputFile *ipf, int completed, + const char *what) { + if (!ipf) return; /* allows showstats to be lazy */ + notice_processed_counts(&ipf->counts, completed, ipf, what); +} + +static void backlog_accumulate_counts(InputFile *ipf) { + int i,j; + if (!ipf) return; + + for (i=0; icounts.results[i][j]; + + for (i=0; icounts.events[i]; + + memset(&ipf->counts, 0, sizeof(ipf->counts)); + backlog_counts_report= 1; +} + void statemc_check_backlog_done(void) { InputFile *ipf= backlog_input_file; if (!inputfile_is_done(ipf)) return; - const char *slash= strrchr(ipf->path, '/'); - const char *leaf= slash ? slash+1 : ipf->path; - const char *under= strchr(slash, '_'); - const char *rest= under ? under+1 : leaf; - if (!strncmp(rest,"backlog",7)) rest += 7; - notice_processed(ipf,1,"backlog ",rest); - + backlog_accumulate_counts(ipf); close_input_file(ipf); if (unlink(ipf->path)) { if (errno != ENOENT) @@ -287,7 +303,7 @@ void statemc_check_flushing_done(void) { assert(sms==sm_SEPARATED || sms==sm_DROPPING); - notice_processed(ipf,1,"feedfile",""); + notice_processed_inputfile(ipf,1,"feedfile"); close_defer(); @@ -484,11 +500,15 @@ void preterminate(void) { } void showstats(void) { - notice_processed(main_input_file,0,"feedfile",""); - notice_processed(flushing_input_file,0,"flushing",""); - if (backlog_input_file) - notice_processed(backlog_input_file,0, "backlog file ", - backlog_input_file->path); + notice_processed_inputfile(main_input_file, 0, "feedfile"); + notice_processed_inputfile(flushing_input_file, 0, "flushing"); + + backlog_accumulate_counts(backlog_input_file); + if (backlog_counts_report) { + notice_processed_counts(&backlog_counts, 0, + backlog_input_file, "backlogs"); + backlog_counts_report= 0; + } until_stats_log= stats_log_periods; }