chiark / gitweb /
options for everything
[innduct.git] / backends / innduct.c
index d75c51bf1467d70cafc35e7d27fd52b6c7773f40..8e599f56026835595780ad3a28725754699fd06f 100644 (file)
@@ -311,32 +311,38 @@ static oop_rd_call peer_rd_err, peer_rd_ok;
 
 /*----- configuration options -----*/
 
-static const char *sitename, *feedfile, *pathoutgoing;
-static const char *remote_host;
-static int quiet_multiple=0, become_daemon=1;
+static const char *sitename, *remote_host;
+static const char *feedfile;
+static int quiet_multiple=0;
+static int become_daemon=1;
+static int try_stream=1;
+static int port=119;
+static const char *inndconffile;
 
-static int max_connections=10, max_queue_per_conn=200;
+static int max_connections=10;
+static int max_queue_per_conn=200;
 static int target_max_feedfile_size=100000;
-
 static int period_seconds=60;
 
-static double max_bad_data_ratio= 0.01;
+static int connection_setup_timeout=200;
+static int inndcomm_flush_timeout=100;
+
+static double nocheck_thresh= 95.0; /* converted from percentage by main */
+static double nocheck_decay= 100; /* conv'd from articles to lambda by main */
+
+/* all these are initialised to seconds, and converted to periods in main */
+static int reconnect_delay_periods=1000;
+static int flushfail_retry_periods=1000;
+static int backlog_retry_minperiods=50;
+static int backlog_spontrescan_periods=300;
+static int spontaneous_flush_periods=100000;
+static int need_activity_periods=1000;
+
+static double max_bad_data_ratio= 1; /* conv'd from percentage by main */
 static 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 */
 
-static int connection_setup_timeout=200, port=119, try_stream=1;
-static int inndcomm_flush_timeout=100;
-static int reconnect_delay_periods, flushfail_retry_periods;
-static int backlog_retry_minperiods, backlog_spontaneous_rescan_periods;
-static int spontaneous_flush_periods, need_activity_periods;
-static const char *inndconffile;
-
-static double nocheck_thresh_pct= 95.0;
-static double nocheck_thresh; /* computed in main from _pct */
-static double nocheck_decay_articles= 100; /* converted to _decay */
-static double nocheck_decay; /* computed in main from _articles */
-
 
 /*----- statistics -----*/
 
@@ -2289,7 +2295,7 @@ static void search_backlog_file(void) {
       xunlink(path_lock, "lockfile for old feed");
       exit(0);
     }
-    until_backlog_nextscan= backlog_spontaneous_rescan_periods;
+    until_backlog_nextscan= backlog_spontrescan_periods;
     goto xfree;
   }
 
@@ -2314,9 +2320,9 @@ static void search_backlog_file(void) {
 
   until_backlog_nextscan= age_deficiency / period_seconds;
 
-  if (backlog_spontaneous_rescan_periods >= 0 &&
-      until_backlog_nextscan > backlog_spontaneous_rescan_periods)
-    until_backlog_nextscan= backlog_spontaneous_rescan_periods;
+  if (backlog_spontrescan_periods >= 0 &&
+      until_backlog_nextscan > backlog_spontrescan_periods)
+    until_backlog_nextscan= backlog_spontrescan_periods;
 
   debug("backlog scan: young age=%f deficiency=%ld nextscan=%d oldest=%s",
        age, age_deficiency, until_backlog_nextscan, oldest_path);
@@ -2681,13 +2687,6 @@ static void op_seconds(const Option *o, const char *val) {
   *store= v;
 }
 
-static void op_periods_rndup(const Option *o, const char *val) {
-  int *store= o->store;
-  op_seconds(o,val);
-  *store += period_seconds-1;
-  *store /= period_seconds;
-}
-
 static void op_setint(const Option *o, const char *val) {
   int *store= o->store;
   *store= o->intval;
@@ -2698,26 +2697,35 @@ static void op_setint(const Option *o, const char *val) {
 static void help(const Option *o, const char *val);
 
 static const Option innduct_options[]= {
-{'f',"feedfile",         "F",   &feedfile,             op_string           },
-{'q',"quiet-multiple",   0,     &quiet_multiple,       op_setint,   1    },
-{0,"help",               0,                            help             },
-
-{0,"max-connections",    "N",   &max_connections,      op_integer          },
-{0,"max-queue-per-conn", "N",   &max_queue_per_conn,   op_integer          },
-
+{'f',"feedfile",         "F",     &feedfile,                 op_string      },
+{'q',"quiet-multiple",   0,       &quiet_multiple,           op_setint, 1   },
+{0,"no-daemon",          0,       &become_daemon,            op_setint, 0   },
+{0,"no-streaming",       0,       &try_stream,               op_setint, 0   },
+{0,"inndconf",           "F",     &inndconffile,             op_string      },
+{'P',"port",             "PORT",  &port,                     op_integer     },
+{0,"help",               0,       0,                         help           },
+
+{0,"max-connections",    "N",     &max_connections,          op_integer     },
+{0,"max-queue-per-conn", "N",     &max_queue_per_conn,       op_integer     },
+{0,"feedfile-flush-size","BYTES", &target_max_feedfile_size, op_integer     },
+{0,"period-interval",    "TIME",  &period_seconds,           op_seconds     },
+
+{0,"connection-timeout", "TIME",  &connection_setup_timeout, op_seconds     },
+{0,"stuck-flush-timeout","TIME",  &inndcomm_flush_timeout,   op_seconds     },
+
+{0,"no-check-proportion",   "PERCENT",   &nocheck_thresh,       op_double   },
+{0,"no-check-response-time","ARTICLES",  &nocheck_decay,        op_double   },
+
+{0,"reconnect-interval",     "PERIOD", &reconnect_delay_periods,  op_seconds },
+{0,"flush-retry-interval",   "PERIOD", &flushfail_retry_periods,  op_seconds },
+{0,"earliest-deferred-retry","PERIOD", &backlog_retry_minperiods, op_seconds },
+{0,"backlog-rescan-interval","PERIOD",&backlog_spontrescan_periods,op_seconds},
+{0,"max-flush-interval",     "PERIOD", &spontaneous_flush_periods,op_seconds },
+{0,"idle-timeout",           "PERIOD", &need_activity_periods,    op_seconds },
+
+{0,"max-bad-input-data-ratio","PERCENT", &max_bad_data_ratio,   op_double    },
+{0,"max-bad-input-data-init", "PERCENT", &max_bad_data_initial, op_integer   },
 
-{0,"streaming",          0,     &try_stream,           op_setint,  1     },
-{0,"no-streaming",       0,     &try_stream,           op_setint,  0     },
-{'P',"port",             "PORT",&port,                 op_integer          },
-{0,"inndconf",           "F",   &inndconffile,         op_string           },
-{0,"no-daemon",          0,     &become_daemon,        op_setint,  0     },
-
-{0,"no-check-proportion","PERCENT", &nocheck_thresh_pct,      op_double },
-{0,"no-check-filter",    "ARTICLES", &nocheck_decay_articles, op_double },
-
-{0,"reconnect-interval",  "TIME", &reconnect_delay_periods, op_periods_rndup },
-{0,"flush-retry-interval","TIME", &flushfail_retry_periods, op_periods_rndup },
-{0,"inndcomm-timeout",    "TIME",  &inndcomm_flush_timeout,   op_seconds },
 {0,0}
 };
 
@@ -2736,6 +2744,11 @@ static void help(const Option *o, const char *val) {
   exit(0);
 }
 
+static void convert_to_periods_rndup(int *store) {
+  *store += period_seconds-1;
+  *store /= period_seconds;
+}
+
 int main(int argc, char **argv) {
   if (!argv[1]) {
     printusage(stderr);
@@ -2755,24 +2768,33 @@ int main(int argc, char **argv) {
 
   if (!remote_host) remote_host= sitename;
 
-  if (nocheck_thresh_pct < 0 || nocheck_thresh_pct > 100)
+  if (nocheck_thresh < 0 || nocheck_thresh > 100)
     badusage("nocheck threshold percentage must be between 0..100");
-  nocheck_thresh= nocheck_thresh_pct * 0.01;
+  nocheck_thresh *= 0.01;
 
-  if (nocheck_decay_articles < 0.1)
+  if (nocheck_decay < 0.1)
     badusage("nocheck decay articles must be at least 0.1");
-  nocheck_decay= 1 - 1/nocheck_decay_articles;
-
-  if (!pathoutgoing)
-    pathoutgoing= innconf->pathoutgoing;
-  innconf_read(inndconffile);
-
-  if (!feedfile)
-    feedfile= xasprintf("%s/%s",pathoutgoing,sitename);
-  else if (!feedfile[0])
+  nocheck_decay= 1 - 1.0/nocheck_decay;
+
+  convert_to_periods_rndup(&reconnect_delay_periods);
+  convert_to_periods_rndup(&flushfail_retry_periods);
+  convert_to_periods_rndup(&backlog_retry_minperiods);
+  convert_to_periods_rndup(&backlog_spontrescan_periods);
+  convert_to_periods_rndup(&spontaneous_flush_periods);
+  convert_to_periods_rndup(&need_activity_periods);
+
+  if (max_bad_data_ratio < 0 || max_bad_data_ratio > 100)
+    badusage("bad input data ratio must be between 0..100");
+  max_bad_data_ratio *= 0.01;
+
+  if (!feedfile) {
+    innconf_read(inndconffile);
+    feedfile= xasprintf("%s/%s",innconf->pathoutgoing,sitename);
+  } else if (!feedfile[0]) {
     badusage("feed filename must be nonempty");
-  else if (feedfile[strlen(feedfile)-1]=='/')
+  } else if (feedfile[strlen(feedfile)-1]=='/') {
     feedfile= xasprintf("%s%s",feedfile,sitename);
+  }
 
   const char *feedfile_forbidden= "?*[~#";
   int c;