static int connection_setup_timeout, port, try_stream;
static int inndcomm_flush_timeout;
static const char *remote_host;
+static int reconnect_delay_periods, flushfail_retry_periods, open_wait_periods;
static double accept_proportion;
static double nocheck_thresh= 0.95;
static StateMachineState sms;
static FILE *defer;
static InputFile *main_input_file, *old_input_file;
-static int waiting_periods_sofar;
+static int sm_period_counter;
/*----- function predeclarations -----*/
}
} else { /*!file_d*/
sms= sm_WAITING;
- statemc_waiting_poll();
+ sm_period_counter= open_wait_periods;
}
}
static void statemc_poll(void) {
- if (sms==sm_WAITING) statemc_waiting_poll();
+ if (sms==sm_WAITING)
+ statemc_waiting_poll();
+
+ if (!sm_period_counter) return;
+ sm_period_counter--;
+ assert(sm_period_counter>=0);
+
+ if (sm_period_counter) return;
+ switch (sms) {
+ case sm_WAITING:
+ die("timed out waiting for innd to create feed file %s", feedfile);
+ case sm_FLUSHFAIL:
+ spawn_inndcomm_flush(void);
+ break;
+ default:
+ abort();
+ }
}
static void statemc_waiting_poll(void) {
InputFile *file_f= open_input_file(feedfile);
- if (!file_f) {
- if (waiting_periods_sofar++ > waiting_timeout_periods)
- die("timed out waiting for innd to create feed file %s", feedfile);
- return;
- }
+ if (!file_f) return;
startup_set_input_file(file_d);
sms= sm_NORMAL;
}
close_input_file(old_input_file);
old_input_file= 0;
+ notice("flush complete");
+
sms= sm_NORMAL;
}
}
} else if (WIFSIGNALED(status) && WTERMSIG(status) == SIGALRM) {
- warn("flush of %s timed out trying to talk to innd", feedname);
+ warn("flush timed out trying to talk to innd");
goto failed;
} else {
unexpected_exitstatus:
}
failed:
-
+ sm_period_counter= flushfail_retry_periods;
+ sms= sm_FLUSHFAIL;;
+}
void spawn_inndcomm_flush(void) {
int pipefds[2];
- assert(sms == sm_NORMAL);
+ assert(sms==sm_NORMAL || sms==sm_FLUSHFAIL);
assert(!inndcomm_child);
if (pipe(pipefds)) sysdie("create pipe for inndcomm child sentinel");
if (!r) exit(0); /* yay! */
if (!strcmp(reply, "1 No such site")) exit(INNDCOMMCHILD_ESTATUS_NONESUCH);
- syswarn("innd ctlinnd flush %s failed: innd said %s", feedname, reply);
+ syswarn("innd ctlinnd flush failed: innd said %s", reply);
exit(INNDCOMMCHILD_ESTATUS_FAIL);
}