Mailing List Archive

r839 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2006-08-19 23:48:30 +0200 (Sat, 19 Aug 2006)
New Revision: 839

Modified:
trunk/varnish-cache/bin/varnishd/cache_acceptor.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Make the session timeout and send timeout tweakables.


Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2006-08-19 21:32:10 UTC (rev 838)
+++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2006-08-19 21:48:30 UTC (rev 839)
@@ -79,7 +79,7 @@
{
struct timeval tv;

- tv.tv_sec = 600;
+ tv.tv_sec = params->send_timeout;
tv.tv_usec = 0;
AZ(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv));
}
@@ -233,7 +233,7 @@
vca_handover(sp, i);
continue;
}
- if (sp->t_idle.tv_sec + 5 < t.tv_sec) {
+ if (sp->t_idle.tv_sec + params->sess_timeout < t.tv_sec) {
TAILQ_REMOVE(&sesshead, sp, list);
vca_unpoll(sp->fd);
vca_close_session(sp, "timeout");
@@ -354,7 +354,7 @@
clock_gettime(CLOCK_MONOTONIC, &t);
TAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) {
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
- if (sp->t_idle.tv_sec + 5 < t.tv_sec) {
+ if (sp->t_idle.tv_sec + params->sess_timeout < t.tv_sec) {
TAILQ_REMOVE(&sesshead, sp, list);
vca_del(sp->fd);
vca_close_session(sp, "timeout");
@@ -400,7 +400,8 @@
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
memset(ke, 0, sizeof ke);
EV_SET(&ke[0], sp->fd, EVFILT_READ, arm, 0, 0, sp);
- EV_SET(&ke[1], sp->fd, EVFILT_TIMER, arm , 0, 5000, sp);
+ EV_SET(&ke[1], sp->fd, EVFILT_TIMER, arm , 0,
+ params->sess_timeout * 1000, sp);
i = kevent(kq, ke, 2, NULL, 0, NULL);
if (arm == EV_ADD)
assert(i == 0);

Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2006-08-19 21:32:10 UTC (rev 838)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2006-08-19 21:48:30 UTC (rev 839)
@@ -39,6 +39,10 @@

/* Memory allocation hints */
unsigned mem_workspace;
+
+ /* Acceptor hints */
+ unsigned sess_timeout;
+ unsigned send_timeout;
};

extern struct params *params;

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2006-08-19 21:32:10 UTC (rev 838)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2006-08-19 21:48:30 UTC (rev 839)
@@ -120,6 +120,46 @@

/*--------------------------------------------------------------------*/

+static void
+tweak_sess_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ unsigned u;
+
+ (void)par;
+ if (arg != NULL) {
+ u = strtoul(arg, NULL, 0);
+ if (u == 0) {
+ cli_out(cli, "Timeout must be greater than zero\n");
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
+ params->sess_timeout = u;
+ }
+ cli_out(cli, "%u [seconds]\n", params->sess_timeout);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
+tweak_send_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
+ unsigned u;
+
+ (void)par;
+ if (arg != NULL) {
+ u = strtoul(arg, NULL, 0);
+ if (u == 0) {
+ cli_out(cli, "Timeout must be greater than zero\n");
+ cli_result(cli, CLIS_PARAM);
+ return;
+ }
+ params->send_timeout = u;
+ }
+ cli_out(cli, "%u [seconds]\n", params->send_timeout);
+}
+
+/*--------------------------------------------------------------------*/
+
/*
* Make sure to end all lines with either a space or newline of the
* formatting will go haywire.
@@ -166,6 +206,21 @@
SHOULD_RESTART
"Default is 4096 bytes. "
"Minimum is 1024 bytes. " },
+ { "sess_timeout", tweak_sess_timeout,
+ "Idle timeout for persistent sessions. "
+ "If a HTTP request has not been received in this many "
+ "seconds, the session is closed.\n"
+#ifdef HAVE_ACCEPT_FILTERS
+ DELAYED_EFFECT
+#endif
+ "Default is 15 seconds. " },
+ { "send_timeout", tweak_send_timeout,
+ "Send timeout for client connections. "
+ "If no data has been sent to the client in this many seconds, "
+ "the session is closed.\n"
+ "See getopt(3) under SO_SNDTIMEO for more information.\n"
+ "Default is 600 seconds. " },
+
{ NULL, NULL, NULL }
};


Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2006-08-19 21:32:10 UTC (rev 838)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2006-08-19 21:48:30 UTC (rev 839)
@@ -333,11 +333,14 @@
params = &param;
mgt_vcc_init();

+ /* XXX: move this to mgt_params.c ?? */
params->default_ttl = 120;
params->wthread_min = 1;
params->wthread_max = UINT_MAX;
params->wthread_timeout = 10;
params->mem_workspace = 4096;
+ params->sess_timeout = 15;
+ params->send_timeout = 600;

while ((o = getopt(argc, argv, "b:df:h:p:s:t:T:Vw:")) != -1)
switch (o) {