/*
* innduct
* tailing reliable realtime streaming feeder for inn
- * main program - option parsing and startup
+ * innduct.c - main program, option parsing and startup
*
* Copyright (C) 2010 Ian Jackson <ijackson@chiark.greenend.org.uk>
*
0
};
-struct Conn {
- ISNODE(Conn);
- int fd; /* may be 0, meaning closed (during construction/destruction) */
- oop_read *rd; /* likewise */
- int oopwriting; /* since on_fd is not idempotent */
- int max_queue, stream;
- const char *quitting;
- int since_activity; /* periods */
- ArticleList waiting; /* not yet told peer */
- ArticleList priority; /* peer says send it now */
- ArticleList sent; /* offered/transmitted - in xmit or waiting reply */
- struct iovec xmit[CONNIOVS];
- XmitDetails xmitd[CONNIOVS];
- int xmitu;
-};
-
/*----- general operational variables -----*/
int lowvol_circptr;
int lowvol_total; /* does not include current period */
+/*---------- configuration option variables ----------*/
+/* when changing defaults, remember to update the manpage */
+
+const char *sitename, *remote_host;
+const char *feedfile, *path_run, *path_cli, *path_cli_dir;
+int quiet_multiple=0;
+int interactive=0, try_filemon=1;
+int try_stream=1;
+int port=119;
+const char *inndconffile;
+
+int max_connections=10;
+int max_queue_per_conn=200;
+int target_max_feedfile_size=100000;
+int period_seconds=30;
+int filepoll_seconds=5;
+int max_queue_per_ipf=-1;
+
+int connection_setup_timeout=200;
+int inndcomm_flush_timeout=100;
+
+double nocheck_thresh= 95.0; /* converted from percentage by main */
+double nocheck_decay= 100; /* conv'd from articles to lambda by main */
+
+/* all these are initialised to seconds, and converted to periods in main */
+int reconnect_delay_periods=1000;
+int flushfail_retry_periods=1000;
+int backlog_retry_minperiods=100;
+int backlog_spontrescan_periods=300;
+int spontaneous_flush_periods=100000;
+int max_separated_periods=2000;
+int need_activity_periods=1000;
+int lowvol_thresh=3;
+int lowvol_periods=1000;
+
+double max_bad_data_ratio= 1; /* conv'd from percentage by main */
+int max_bad_data_initial= 30;
+ /* in one corrupt 4096-byte block the number of newlines has
+ * mean 16 and standard deviation 3.99. 30 corresponds to z=+3.5 */
+
/*========== main program ==========*/
static void postfork_inputfile(InputFile *ipf) {
every_schedule(e, now);
}
-static char *dbg_report_ipf(InputFile *ipf) {
- if (!ipf) return xasprintf("none");
-
- const char *slash= strrchr(ipf->path,'/');
- const char *path= slash ? slash+1 : ipf->path;
-
- return xasprintf("%p/%s:queue=%d,ip=%ld,autodef=%ld,off=%ld,fd=%d%s%s%s",
- ipf, path,
- ipf->queue.count, ipf->inprogress, ipf->autodefer,
- (long)ipf->offset, ipf->fd,
- ipf->rd ? "" : ",!rd",
- ipf->skippinglong ? "*skiplong" : "",
- ipf->rd && ipf->paused ? "*paused" : "");
-}
-
-static void period(void) {
+void period(void) {
char *dipf_main= dbg_report_ipf(main_input_file);
char *dipf_flushing= dbg_report_ipf(flushing_input_file);
char *dipf_backlog= dbg_report_ipf(backlog_input_file);
return specified[l-1] == '/';
}
+static int innduct_fatal_cleanup(void) { return 12; } /* used for libinn die */
+
int main(int argc, char **argv) {
/* set up libinn logging */
message_program_name= "innduct";
message_fatal_cleanup= innduct_fatal_cleanup;
+
+#define INNLOGSET_CALL(fn, pfx, sysloglevel) \
+ message_handlers_##fn(1, duct_log_##fn);
INNLOGSETS(INNLOGSET_CALL)
if (!argv[1]) {