Mailing List Archive

r899 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2006-08-23 08:55:18 +0200 (Wed, 23 Aug 2006)
New Revision: 899

Modified:
trunk/varnish-cache/bin/varnishd/cache_pipe.c
trunk/varnish-cache/bin/varnishd/heritage.h
trunk/varnish-cache/bin/varnishd/mgt.h
trunk/varnish-cache/bin/varnishd/mgt_param.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Move defaults from varnishd.c to mgt_param.c and use regular functions
for setting them.

Collapse all the 'timeout' functions.

Add pipe_timeout parameter.



Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-08-23 06:53:28 UTC (rev 898)
+++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2006-08-23 06:55:18 UTC (rev 899)
@@ -12,6 +12,7 @@
#include <sys/socket.h>

#include "shmlog.h"
+#include "heritage.h"
#include "cache.h"

static void
@@ -83,7 +84,7 @@
while (fds[0].events || fds[1].events) {
fds[0].revents = 0;
fds[1].revents = 0;
- i = poll(fds, 2, 600000);
+ i = poll(fds, 2, params->pipe_timeout * 1000);
if (i != 1)
break;
if (fds[0].revents)

Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h 2006-08-23 06:53:28 UTC (rev 898)
+++ trunk/varnish-cache/bin/varnishd/heritage.h 2006-08-23 06:55:18 UTC (rev 899)
@@ -42,6 +42,7 @@

/* Acceptor hints */
unsigned sess_timeout;
+ unsigned pipe_timeout;
unsigned send_timeout;

/* Management hints */

Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h 2006-08-23 06:53:28 UTC (rev 898)
+++ trunk/varnish-cache/bin/varnishd/mgt.h 2006-08-23 06:55:18 UTC (rev 899)
@@ -22,6 +22,9 @@
void mgt_cli_stop_child(void);
int mgt_cli_telnet(const char *T_arg);

+/* mgt_param.c */
+void MCF_ParamInit(void);
+
/* mgt_vcc.c */
void mgt_vcc_init(void);
int mgt_vcc_default(const char *bflag, const char *fflag);

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c 2006-08-23 06:53:28 UTC (rev 898)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2006-08-23 06:55:18 UTC (rev 899)
@@ -22,17 +22,41 @@
const char *name;
tweak_t *func;
const char *expl;
+ const char *def;
};

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

static void
+tweak_generic_timeout(struct cli *cli, unsigned *dst, const char *arg)
+{
+ unsigned u;
+
+ 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;
+ }
+ *dst = u;
+ }
+ if (cli == NULL)
+ return;
+ cli_out(cli, "%u [seconds]\n", *dst);
+}
+
+/*--------------------------------------------------------------------*/
+
+static void
tweak_default_ttl(struct cli *cli, struct parspec *par, const char *arg)
{

(void)par;
if (arg != NULL)
params->default_ttl = strtoul(arg, NULL, 0);
+ if (cli == NULL)
+ return;
cli_out(cli, "%u [seconds]\n", params->default_ttl);
}

@@ -53,6 +77,8 @@
}
params->wthread_min = u;
}
+ if (cli == NULL)
+ return;
cli_out(cli, "%u [threads]\n", params->wthread_min);
}

@@ -73,6 +99,8 @@
}
params->wthread_max = u;
}
+ if (cli == NULL)
+ return;
if (params->wthread_max == UINT_MAX)
cli_out(cli, "unlimited\n");
else
@@ -84,20 +112,11 @@
static void
tweak_thread_pool_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->wthread_timeout = u;
- }
- cli_out(cli, "%u [seconds]\n", params->wthread_timeout);
+ tweak_generic_timeout(cli, &params->wthread_timeout, arg);
}
+
/*--------------------------------------------------------------------*/

static void
@@ -115,6 +134,8 @@
}
params->mem_workspace = u;
}
+ if (cli == NULL)
+ return;
cli_out(cli, "%u [bytes]\n", params->mem_workspace);
}

@@ -123,19 +144,17 @@
static void
tweak_sess_timeout(struct cli *cli, struct parspec *par, const char *arg)
{
- unsigned u;
+ (void)par;
+ tweak_generic_timeout(cli, &params->sess_timeout, arg);
+}

+/*--------------------------------------------------------------------*/
+
+static void
+tweak_pipe_timeout(struct cli *cli, struct parspec *par, const char *arg)
+{
(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);
+ tweak_generic_timeout(cli, &params->pipe_timeout, arg);
}

/*--------------------------------------------------------------------*/
@@ -143,19 +162,8 @@
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);
+ tweak_generic_timeout(cli, &params->send_timeout, arg);
}

/*--------------------------------------------------------------------*/
@@ -175,6 +183,8 @@
}
params->auto_restart = u;
}
+ if (cli == NULL)
+ return;
cli_out(cli, "%u {1 = yes, 0 = no}\n", params->auto_restart);
}

@@ -205,46 +215,48 @@
"made until they are fetched from the backend again.\n"
"To force an immediate effect at the expense of a total "
"flush of the cache use \"url.purge .\"\n"
- "Default is 120 seconds. " },
+ "Default is 120 seconds. ", "120" },
+ { "thread_pool_max", tweak_thread_pool_max,
+ "The maximum number of threads in the worker pool.\n"
+ DELAYED_EFFECT
+ "Default is no limit.", "-1" },
{ "thread_pool_min", tweak_thread_pool_min,
"The minimum number of threads in the worker pool.\n"
DELAYED_EFFECT
"Default is 1 thread. "
- "Minimum is 1 thread. " },
- { "thread_pool_max", tweak_thread_pool_max,
- "The maximum number of threads in the worker pool.\n"
- DELAYED_EFFECT
- "Default is no limit." },
+ "Minimum is 1 thread. ", "1" },
{ "thread_pool_timeout", tweak_thread_pool_timeout,
"Thread dies after this many seconds of inactivity.\n"
"Default is 10 seconds. "
- "Minimum is 1 second. " },
+ "Minimum is 1 second. ", "10" },
{ "http_workspace", tweak_http_workspace,
"Bytes of HTTP protocol workspace allocated. "
"This space must be big enough for the entire HTTP protocol "
"header and any edits done to it in the VCL code.\n"
SHOULD_RESTART
"Default is 4096 bytes. "
- "Minimum is 1024 bytes. " },
+ "Minimum is 1024 bytes. ", "4096" },
{ "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. " },
+ "Default is 5 seconds. ", "5" },
+ { "pipe_timeout", tweak_pipe_timeout,
+ "Idle timeout for PIPE sessions. "
+ "If nothing have been received in either directoin for "
+ "this many seconds, the session is closed.\n"
+ "Default is 60 seconds. ", "60" },
{ "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"
DELAYED_EFFECT
"See getopt(3) under SO_SNDTIMEO for more information.\n"
- "Default is 600 seconds. " },
+ "Default is 600 seconds. ", "600" },
{ "auto_restart", tweak_auto_restart,
"Restart child process automatically if it dies. "
"1 = yes, 0 = no.\n"
- "Default is 1. " },
+ "Default is 1. ", "1" },
{ NULL, NULL, NULL }
};

@@ -325,3 +337,13 @@
}
}

+/*--------------------------------------------------------------------*/
+
+void
+MCF_ParamInit(void)
+{
+ struct parspec *pp;
+
+ for (pp = parspec; pp->name != NULL; pp++)
+ pp->func(NULL, pp, pp->def);
+}

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2006-08-23 06:53:28 UTC (rev 898)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2006-08-23 06:55:18 UTC (rev 899)
@@ -336,15 +336,7 @@
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 = 60;
- params->mem_workspace = 4096;
- params->sess_timeout = 5;
- params->send_timeout = 600;
- params->auto_restart = 1;
+ MCF_ParamInit();

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