chiark / gitweb /
make period size a tuneable
authorIan Jackson <ian@liberator.(none)>
Tue, 27 Apr 2010 11:41:28 +0000 (12:41 +0100)
committerIan Jackson <ian@liberator.(none)>
Tue, 27 Apr 2010 11:41:28 +0000 (12:41 +0100)
backends/innduct.c

index 47561e397b891ce941cab02f575c3cf3f6cfd5ce..1328d372f8d8390cb822f734a2476f044b1c6404 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * TODO
 /*
  * TODO
- *  - make period size a tuneable
  *  - check all structs initialised
  *  - check all fd watches properly undone
  *  - check all init functions called
  *  - check all structs initialised
  *  - check all fd watches properly undone
  *  - check all init functions called
@@ -195,8 +194,6 @@ perl -ne 'print if m/-8\<-/..m/-\>8-/; print "\f" if m/-\^L-/' backends/innduct.
 
 /*----- general definitions, probably best not changed -----*/
 
 
 /*----- general definitions, probably best not changed -----*/
 
-#define PERIOD_SECONDS 60
-
 #define CONNCHILD_ESTATUS_STREAM   4
 #define CONNCHILD_ESTATUS_NOSTREAM 5
 
 #define CONNCHILD_ESTATUS_STREAM   4
 #define CONNCHILD_ESTATUS_NOSTREAM 5
 
@@ -316,6 +313,8 @@ static int quiet_multiple=0, become_daemon=1;
 static int max_connections=10, max_queue_per_conn=200;
 static int target_max_feedfile_size=100000;
 
 static int max_connections=10, 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 max_bad_data_initial= 30;
   /* in one corrupt 4096-byte block the number of newlines has
 static double max_bad_data_ratio= 0.01;
 static int max_bad_data_initial= 30;
   /* in one corrupt 4096-byte block the number of newlines has
@@ -2247,7 +2246,7 @@ static void search_backlog_file(void) {
 
   now= xtime();
   double age= difftime(now, oldest_mtime);
 
   now= xtime();
   double age= difftime(now, oldest_mtime);
-  long age_deficiency= (backlog_retry_minperiods * PERIOD_SECONDS) - age;
+  long age_deficiency= (backlog_retry_minperiods * period_seconds) - age;
 
   if (age_deficiency <= 0) {
     debug("backlog scan: found age=%f deficiency=%ld oldest=%s",
 
   if (age_deficiency <= 0) {
     debug("backlog scan: found age=%f deficiency=%ld oldest=%s",
@@ -2263,7 +2262,7 @@ static void search_backlog_file(void) {
     return;
   }
 
     return;
   }
 
-  until_backlog_nextscan= age_deficiency / PERIOD_SECONDS;
+  until_backlog_nextscan= age_deficiency / period_seconds;
 
   if (backlog_spontaneous_rescan_periods >= 0 &&
       until_backlog_nextscan > backlog_spontaneous_rescan_periods)
 
   if (backlog_spontaneous_rescan_periods >= 0 &&
       until_backlog_nextscan > backlog_spontaneous_rescan_periods)
@@ -2414,8 +2413,7 @@ static void postfork(const char *what) {
 }
 
 #define EVERY(what, interval_sec, interval_usec, body)                      \
 }
 
 #define EVERY(what, interval_sec, interval_usec, body)                      \
-  static const struct timeval what##_timeout =                              \
-            { interval_sec, interval_usec };                                \
+  static struct timeval what##_timeout = { interval_sec, interval_usec };    \
   static void what##_schedule(void);                                        \
   static void *what##_timedout(oop_source *lp, struct timeval tv, void *u) { \
     { body }                                                                \
   static void what##_schedule(void);                                        \
   static void *what##_timedout(oop_source *lp, struct timeval tv, void *u) { \
     { body }                                                                \
@@ -2440,7 +2438,7 @@ static const char *debug_ipf_path(InputFile *ipf) {
   return slash ? slash+1 : ipf->path;
 }
 
   return slash ? slash+1 : ipf->path;
 }
 
-EVERY(period, PERIOD_SECONDS,0, {
+EVERY(period, -1,0, {
   debug("PERIOD"
        " sms=%s[%d] conns=%d queue=%d until_connect=%d"
        " input_files" DEBUGF_IPF(main) DEBUGF_IPF(old) DEBUGF_IPF(flushing)
   debug("PERIOD"
        " sms=%s[%d] conns=%d queue=%d until_connect=%d"
        " input_files" DEBUGF_IPF(main) DEBUGF_IPF(old) DEBUGF_IPF(flushing)
@@ -2542,8 +2540,8 @@ static void op_seconds(const Option *o, const char *val) {
 static void op_periods_rndup(const Option *o, const char *val) {
   int *store= o->store;
   op_seconds(o,val);
 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;
+  *store += period_seconds-1;
+  *store /= period_seconds;
 }
 
 static void op_setint(const Option *o, const char *val) {
 }
 
 static void op_setint(const Option *o, const char *val) {
@@ -2697,6 +2695,7 @@ int main(int argc, char **argv) {
     filepoll_schedule();
   }
 
     filepoll_schedule();
   }
 
+  period_timeout.tv_sec= period_seconds;
   period_schedule();
 
   statemc_init();
   period_schedule();
 
   statemc_init();