chiark
/
gitweb
/
~ian
/
inn-innduct.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
admin-initiated flush
[inn-innduct.git]
/
backends
/
innduct.c
diff --git
a/backends/innduct.c
b/backends/innduct.c
index f1f8fd4a9ae6edb0ab54345bd6e45b5dac7c0568..3da59e101c02dfc3134e71857d4e4ca8b6b71af9 100644
(file)
--- a/
backends/innduct.c
+++ b/
backends/innduct.c
@@
-1,7
+1,6
@@
/*
* todo
* - manpage: document control master stuff
/*
* todo
* - manpage: document control master stuff
- * - admin-initiated flush
*
* debugging rune:
* build-lfs/backends/innduct --connection-timeout=30 --no-daemon -C ../inn.conf -f `pwd`/fee sit localhost
*
* debugging rune:
* build-lfs/backends/innduct --connection-timeout=30 --no-daemon -C ../inn.conf -f `pwd`/fee sit localhost
@@
-297,6
+296,7
@@
static void statemc_setstate(StateMachineState newsms, int periods,
static void statemc_start_flush(const char *why); /* Normal => Flushing */
static void spawn_inndcomm_flush(const char *why); /* Moved => Flushing */
static void statemc_start_flush(const char *why); /* Normal => Flushing */
static void spawn_inndcomm_flush(const char *why); /* Moved => Flushing */
+static int trigger_flush_ok(void); /* => Flushing,FLUSHING, ret 1; or ret 0 */
static void article_done(Conn *conn, Article *art, int whichcount);
static void article_done(Conn *conn, Article *art, int whichcount);
@@
-818,11
+818,10
@@
CCMD(help) {
fprintf(cc->out, " %s\n", ccmd->cmd);
}
fprintf(cc->out, " %s\n", ccmd->cmd);
}
-CCMD(period) { period(); }
-CCMD(setintarg) { *(int*)c->xdata= atoi(arg); }
-CCMD(setint) { *(int*)c->xdata= c->xval; }
-CCMD(setint_period) { *(int*)c->xdata= c->xval; period(); }
-CCMD(dump);
+CCMD(flush) {
+ int ok= trigger_flush_ok();
+ if (!ok) fprintf(cc->out,"already flushing (state is %s)\n", sms_names[sms]);
+}
CCMD(stop) {
preterminate();
CCMD(stop) {
preterminate();
@@
-831,13
+830,23
@@
CCMD(stop) {
abort();
}
abort();
}
+CCMD(dump);
+
+/* messing with our head: */
+CCMD(period) { period(); }
+CCMD(setintarg) { *(int*)c->xdata= atoi(arg); }
+CCMD(setint) { *(int*)c->xdata= c->xval; }
+CCMD(setint_period) { *(int*)c->xdata= c->xval; period(); }
+
static const ControlCommand control_commands[]= {
{ "h", ccmd_help },
static const ControlCommand control_commands[]= {
{ "h", ccmd_help },
- { "
p", ccmd_period
},
+ { "
flush", ccmd_flush
},
{ "stop", ccmd_stop },
{ "dump q", ccmd_dump, 0,0 },
{ "dump a", ccmd_dump, 0,1 },
{ "stop", ccmd_stop },
{ "dump q", ccmd_dump, 0,0 },
{ "dump a", ccmd_dump, 0,1 },
+ { "p", ccmd_period },
+
#define POKES(cmd,func) \
{ cmd "sm", func, &sm_period_counter, 1 }, \
{ cmd "conn", func, &until_connect, 0 }, \
#define POKES(cmd,func) \
{ cmd "sm", func, &sm_period_counter, 1 }, \
{ cmd "conn", func, &until_connect, 0 }, \
@@
-2441,24
+2450,29
@@
static void statemc_start_flush(const char *why) { /* Normal => Flushing */
spawn_inndcomm_flush(why); /* => Flushing FLUSHING */
}
spawn_inndcomm_flush(why); /* => Flushing FLUSHING */
}
-static void statemc_period_poll(void) {
- if (!sm_period_counter) return;
- sm_period_counter--;
- assert(sm_period_counter>=0);
-
- if (sm_period_counter) return;
+static int trigger_flush_ok(void) { /* => Flushing,FLUSHING, ret 1; or ret 0 */
switch (sms) {
case sm_NORMAL:
statemc_start_flush("periodic"); /* Normal => Flushing; => FLUSHING */
switch (sms) {
case sm_NORMAL:
statemc_start_flush("periodic"); /* Normal => Flushing; => FLUSHING */
-
break
;
+
return 1
;
case sm_FLUSHFAILED:
spawn_inndcomm_flush("retry"); /* Moved => Flushing; => FLUSHING */
case sm_FLUSHFAILED:
spawn_inndcomm_flush("retry"); /* Moved => Flushing; => FLUSHING */
-
break
;
+
return 1
;
default:
default:
-
abort()
;
+
return 0
;
}
}
}
}
+static void statemc_period_poll(void) {
+ if (!sm_period_counter) return;
+ sm_period_counter--;
+ assert(sm_period_counter>=0);
+
+ if (sm_period_counter) return;
+ int ok= trigger_flush_ok();
+ assert(ok);
+}
+
static int inputfile_is_done(InputFile *ipf) {
if (!ipf) return 0;
if (ipf->inprogress) return 0; /* new article in the meantime */
static int inputfile_is_done(InputFile *ipf) {
if (!ipf) return 0;
if (ipf->inprogress) return 0; /* new article in the meantime */