chiark / gitweb /
Support caller simply setting CFLAGS
[innduct.git] / statemc.c
index 58aaefd6413fec8a5ee4a2ddd6109d01ef51c300..b068722a15e339f81e7639341110c2ab977f433e 100644 (file)
--- a/statemc.c
+++ b/statemc.c
@@ -190,8 +190,12 @@ int trigger_flush_ok(const char *why) {
 
   case sm_SEPARATED:
   case sm_DROPPING:
-    warn("abandoning old feedfile after flush (%s), autodeferring",
-        why ? why : "took too long to complete");
+    if (conns.count)
+      warn("abandoning old feedfile after flush (%s), autodeferring",
+          why ? why : "took too long to complete");
+    else
+      info("autodeferring after flush (%s)",
+          why ? why : "no connections");
     assert(flushing_input_file);
     autodefer_input_file(flushing_input_file);
     return 1;
@@ -228,13 +232,13 @@ static void notice_processed_counts(Counts *counts, int completed,
 #define CNT(art,rc) (counts->results[art_##art][RC_##rc])
 
   char *inprog= ipf_xtra && !completed
-    ? xasprintf(" inprogress=%ld", ipf_xtra->inprogress)
-    : xasprintf("%s",""); /* GCC produces a stupid warning for printf("") ! */
+    ? masprintf(" inprogress=%ld", ipf_xtra->inprogress)
+    : masprintf("%s",""); /* GCC produces a stupid warning for printf("") ! */
   char *autodefer= ipf_xtra && ipf_xtra->autodefer >= 0
-    ? xasprintf(" autodeferred=%ld", ipf_xtra->autodefer)
-    : xasprintf("%s","");
+    ? masprintf(" autodeferred=%ld", ipf_xtra->autodefer)
+    : masprintf("%s","");
 
-  info("%s %s read=%d (+bl=%d,+err=%d)%s%s"
+  notice("%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)
        ,
@@ -282,6 +286,7 @@ void statemc_check_backlog_done(void) {
   InputFile *ipf= backlog_input_file;
   if (!inputfile_is_done(ipf)) return;
 
+  dbg("backlog file %p %s complete", ipf, ipf->path);
   backlog_accumulate_counts(ipf);
   close_input_file(ipf);
   if (unlink(ipf->path)) {
@@ -303,7 +308,7 @@ void statemc_check_flushing_done(void) {
 
   assert(sms==sm_SEPARATED || sms==sm_DROPPING);
 
-  notice_processed_inputfile(ipf,1,"feedfile");
+  notice_processed_inputfile(ipf,1,"batch");
 
   close_defer();
 
@@ -500,6 +505,7 @@ void preterminate(void) {
 }
 
 void showstats(void) {
+  notice_conns_stats();
   notice_processed_inputfile(main_input_file,     0, "feedfile");
   notice_processed_inputfile(flushing_input_file, 0, "flushing");
 
@@ -530,6 +536,7 @@ static void *sigarrived_event(oop_source *lp, int fd, oop_event e, void *u) {
 }
 
 static void sigarrived_handler(int signum) {
+  int esave = errno;
   static char x;
   switch (signum) {
   case SIGTERM:
@@ -539,7 +546,9 @@ static void sigarrived_handler(int signum) {
   default:
     abort();
   }
-  write(signal_self_pipe[1],&x,1);
+  int r = write(signal_self_pipe[1],&x,1);
+  if (!(r==1 || isewouldblock(errno))) abort();
+  errno = esave;
 }
 
 void init_signals(void) {