/*
* todo
+ * - abolish xk_Malloc
+ * - rename sm_period_counter as it's just about flushes
* - 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
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);
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();
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 },
- { "p", ccmd_period },
+ { "flush", ccmd_flush },
{ "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 }, \
ipf->readcount_ok++;
art= xmalloc(sizeof(*art) - 1 + midlen + 1);
- memset(art,0,sizeof(art));
+ memset(art,0,sizeof(*art));
art->state= art_Unchecked;
art->midlen= midlen;
art->ipf= ipf; ipf->inprogress++;
| flsh->rd!=0 | | flsh->rd!=0
| [Separated] | | [Dropping]
| main F idle | | main none
- | old D tail | | old D tail
+ | flsh D tail | | flsh D tail
| ============= | | ============
| | | | install |
^ | EOF ON D | | defer | EOF ON D
| flsh->rd==0 | V flsh->rd==0
| [Finishing] | | [Dropping]
| main F tail | `. main none
- | old D closed | `. old D closed
+ | flsh D closed | `. flsh D closed
| =============== V `. ===============
| | `. |
| | ALL D PROCESSED `. | ALL D PROCESSED
DROPPED
[Dropped]
main none
- old none
+ flsh none
some backlog
==============
|
if (file_d) {
debug("startup: F!=D => Separated");
startup_set_input_file(file_d);
+ flushing_input_file= main_input_file;
+ main_input_file= open_input_file(feedfile);
+ if (!main_input_file) die("feedfile vanished during startup");
SMS(SEPARATED, 0, "found both old and current feed files");
} else {
debug("startup: F exists, D ENOENT => Normal");
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 */
- break;
+ return 1;
case sm_FLUSHFAILED:
spawn_inndcomm_flush("retry"); /* Moved => Flushing; => FLUSHING */
- break;
+ return 1;
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 void preterminate(void) {
if (in_child) return;
notice_processed(main_input_file,0,"feedfile","");
- notice_processed(flushing_input_file,0,"flushing file","");
+ notice_processed(flushing_input_file,0,"flushing","");
if (backlog_input_file)
notice_processed(backlog_input_file,0, "backlog file ",
backlog_input_file->path);