Commit 61ece1a2 authored by Geoff Simmons's avatar Geoff Simmons

add config parameter idle.pause

parent 611ef797
...@@ -86,6 +86,20 @@ conf_getUnsignedInt(const char *rval, unsigned *i) ...@@ -86,6 +86,20 @@ conf_getUnsignedInt(const char *rval, unsigned *i)
return(0); return(0);
} }
static int
conf_getDouble(const char *rval, double *d)
{
char *p;
errno = 0;
double x = strtod(rval, &p);
if (errno == ERANGE)
return errno;
if (p[0] != '\0' || x < 0 || isnan(x) || !finite(x))
return EINVAL;
*d = x;
return 0;
}
#define confString(name,fld) \ #define confString(name,fld) \
if (strcmp(lval, (name)) == 0) { \ if (strcmp(lval, (name)) == 0) { \
strcpy((config.fld), rval); \ strcpy((config.fld), rval); \
...@@ -155,17 +169,23 @@ CONF_Add(const char *lval, const char *rval) ...@@ -155,17 +169,23 @@ CONF_Add(const char *lval, const char *rval)
} }
if (strcmp(lval, "output.timeout") == 0) { if (strcmp(lval, "output.timeout") == 0) {
char *p; double to;
errno = 0; int err = conf_getDouble(rval, &to);
double to = strtod(rval, &p); if (err != 0)
if (errno == ERANGE) return err;
return errno;
if (p[0] != '\0' || to < 0 || isnan(to) || !finite(to))
return EINVAL;
config.output_timeout = VTIM_timeval(to); config.output_timeout = VTIM_timeval(to);
return(0); return(0);
} }
if (strcmp(lval, "idle.pause") == 0) {
double pause;
int err = conf_getDouble(rval, &pause);
if (err != 0)
return err;
config.idle_pause = pause;
return(0);
}
return EINVAL; return EINVAL;
} }
...@@ -221,6 +241,7 @@ CONF_Init(void) ...@@ -221,6 +241,7 @@ CONF_Init(void)
config.chunk_size = DEFAULT_CHUNK_SIZE; config.chunk_size = DEFAULT_CHUNK_SIZE;
config.housekeep_interval = DEFAULT_HOUSEKEEP_INTERVAL; config.housekeep_interval = DEFAULT_HOUSEKEEP_INTERVAL;
config.ttl = DEFAULT_TTL; config.ttl = DEFAULT_TTL;
config.idle_pause = DEFAULT_IDLE_PAUSE;
/* Default is stdout */ /* Default is stdout */
config.output_file[0] = '\0'; config.output_file[0] = '\0';
...@@ -320,6 +341,7 @@ CONF_Dump(void) ...@@ -320,6 +341,7 @@ CONF_Dump(void)
confdump("max.data = %u", config.max_data); confdump("max.data = %u", config.max_data);
confdump("housekeep.interval = %u", config.housekeep_interval); confdump("housekeep.interval = %u", config.housekeep_interval);
confdump("ttl = %u", config.ttl); confdump("ttl = %u", config.ttl);
confdump("idle.pause = %d", config.idle_pause);
confdump("output.bufsiz = %u", config.output_bufsiz); confdump("output.bufsiz = %u", config.output_bufsiz);
confdump("user = %s", config.user_name); confdump("user = %s", config.user_name);
} }
...@@ -681,9 +681,7 @@ main(int argc, char *argv[]) ...@@ -681,9 +681,7 @@ main(int argc, char *argv[])
continue; continue;
case DISPATCH_EOL: case DISPATCH_EOL:
take_free(); take_free();
#if 0 VTIM_sleep(config.idle_pause);
TIM_sleep(config.idle_pause);
#endif
continue; continue;
case DISPATCH_TERMINATE: case DISPATCH_TERMINATE:
assert(term == 1); assert(term == 1);
......
...@@ -61,6 +61,8 @@ ...@@ -61,6 +61,8 @@
#define DEFAULT_MAX_DATA 4096 #define DEFAULT_MAX_DATA 4096
#define DEFAULT_PID_FILE "/var/run/varnishevent.pid" #define DEFAULT_PID_FILE "/var/run/varnishevent.pid"
#define DEFAULT_IDLE_PAUSE 0.01
#define DEFAULT_HOUSEKEEP_INTERVAL 10 #define DEFAULT_HOUSEKEEP_INTERVAL 10
#define DEFAULT_TTL 120 #define DEFAULT_TTL 120
...@@ -171,7 +173,9 @@ struct config { ...@@ -171,7 +173,9 @@ struct config {
char output_file[PATH_MAX]; char output_file[PATH_MAX];
unsigned append; unsigned append;
struct timeval output_timeout; struct timeval output_timeout;
double idle_pause;
/* VSL 'r' argument */ /* VSL 'r' argument */
char varnish_bindump[BUFSIZ]; char varnish_bindump[BUFSIZ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment