From 63646956496f0252f60f28fb87117642d9e668d7 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 24 Mar 2010 00:25:28 +0000 Subject: [PATCH] New flush completion --- backends/innduct.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/backends/innduct.c b/backends/innduct.c index 54e6196..33adaf8 100644 --- a/backends/innduct.c +++ b/backends/innduct.c @@ -153,6 +153,7 @@ static int max_connections, max_queue_per_conn; 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; @@ -281,7 +282,7 @@ static char *path_ductlock, *path_duct, *path_ductdefer; 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 -----*/ @@ -1457,21 +1458,33 @@ static void statemc_init(void) { } } 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; } @@ -1520,6 +1533,8 @@ static void *statemc_check_oldinput_done(oop_source *lp, close_input_file(old_input_file); old_input_file= 0; + notice("flush complete"); + sms= sm_NORMAL; } @@ -1566,7 +1581,7 @@ static void *inndcomm_event(oop_source *lp, int fd, oop_event e, void *u) { } } 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: @@ -1574,12 +1589,14 @@ static void *inndcomm_event(oop_source *lp, int fd, oop_event e, void *u) { } 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"); @@ -1598,7 +1615,7 @@ void spawn_inndcomm_flush(void) { 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); } -- 2.30.2