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 */
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
-#define RCI_TRIPLE_VALS(x) , RCI_TRIPLE_VALS_BASE(ipf->counts, [RC_##x])
+#define RCI_TRIPLE_VALS(x) ,RCI_TRIPLE_VALS_BASE(ipf->counts.results, [RC_##x])
-#define CNT(art,rc) (ipf->counts[art_##art][RC_##rc])
+#define CNT(art,rc) (ipf->counts.results[art_##art][RC_##rc])
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,
- ipf->readcount_ok, ipf->readcount_blank, ipf->readcount_err,
- inprog, autodefer, ipf->count_nooffer_missing,
+ 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],
CNT(Unchecked,sent) + CNT(Unsolicited,sent)
, CNT(Unchecked,sent), CNT(Unsolicited,sent),
CNT(Wanted,accepted) + CNT(Unsolicited,accepted)
RESULT_COUNTS(RCI_NOTHING, RCI_TRIPLE_VALS)
);
- memset(ipf->counts, 0, sizeof(ipf->counts));
- ipf->readcount_ok= ipf->readcount_blank=
- ipf->readcount_err= ipf->count_nooffer_missing= 0;
+ memset(&ipf->counts, 0, sizeof(ipf->counts));
free(inprog);
free(autodefer);
#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; i<art_MaxState; i++)
+ for (j=0; j<RCI_max; j++)
+ backlog_counts.results[i][j] += ipf->counts.results[i][j];
+
+ for (i=0; i<ECI_max; i++)
+ backlog_counts.events[i] += ipf->counts.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)
assert(sms==sm_SEPARATED || sms==sm_DROPPING);
- notice_processed(ipf,1,"feedfile","");
+ notice_processed_inputfile(ipf,1,"feedfile");
close_defer();
}
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;
}