[master] 8241149 Draw the line between the managers and the childs copy of the struct params much clearer. Manager should never read the childs copy.
Poul-Henning Kamp
phk at varnish-cache.org
Thu Nov 10 11:08:41 CET 2011
commit 8241149492e5649c8a3126ee363f089f33491655
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Nov 10 08:57:41 2011 +0000
Draw the line between the managers and the childs copy of the struct
params much clearer. Manager should never read the childs copy.
diff --git a/bin/varnishd/cache_main.c b/bin/varnishd/cache_main.c
index 8293d38..c610bc3 100644
--- a/bin/varnishd/cache_main.c
+++ b/bin/varnishd/cache_main.c
@@ -37,6 +37,8 @@
#include "waiter/cache_waiter.h"
#include "hash/hash_slinger.h"
+volatile struct params *params;
+
/*--------------------------------------------------------------------
* Per thread storage for the session currently being processed by
* the thread. This is used for panic messages.
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 1656af8..61493b3 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -58,10 +58,11 @@ void mgt_cli_secret(const char *S_arg);
void mgt_cli_close_all(void);
/* mgt_param.c */
-void MCF_ParamSync(void);
void MCF_ParamInit(struct cli *);
void MCF_ParamSet(struct cli *, const char *param, const char *val);
void MCF_DumpRst(void);
+extern struct params mgt_param;
+
/* mgt_sandbox.c */
void mgt_sandbox(void);
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index ff8a776..9c6d37d 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -214,7 +214,7 @@ MGT_Child_Cli_Fail(void)
return;
REPORT(LOG_ERR, "Child (%jd) not responding to CLI, killing it.",
(intmax_t)child_pid);
- if (params->diag_bitmap & 0x1000)
+ if (mgt_param.diag_bitmap & 0x1000)
(void)kill(child_pid, SIGKILL);
else
(void)kill(child_pid, SIGQUIT);
@@ -315,7 +315,7 @@ start_child(struct cli *cli)
heritage.std_fd = cp[1];
child_output = cp[0];
- MCF_ParamSync();
+ AN(params);
if ((pid = fork()) < 0) {
perror("Could not fork child");
exit(1);
@@ -374,10 +374,10 @@ start_child(struct cli *cli)
AZ(vev_add(mgt_evb, e));
ev_listen = e;
AZ(ev_poker);
- if (params->ping_interval > 0) {
+ if (mgt_param.ping_interval > 0) {
e = vev_new();
XXXAN(e);
- e->timeout = params->ping_interval;
+ e->timeout = mgt_param.ping_interval;
e->callback = child_poker;
e->name = "child poker";
AZ(vev_add(mgt_evb, e));
@@ -522,7 +522,7 @@ mgt_sigchld(const struct vev *e, int what)
REPORT0(LOG_DEBUG, "Child cleanup complete");
- if (child_state == CH_DIED && params->auto_restart)
+ if (child_state == CH_DIED && mgt_param.auto_restart)
start_child(NULL);
else if (child_state == CH_DIED) {
child_state = CH_STOPPED;
diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c
index c8f22c3..ec8fd4d 100644
--- a/bin/varnishd/mgt/mgt_cli.c
+++ b/bin/varnishd/mgt/mgt_cli.c
@@ -170,7 +170,7 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv)
return;
}
VSB_delete(vsb);
- (void)VCLI_ReadResult(cli_i, &u, &q, params->cli_timeout);
+ (void)VCLI_ReadResult(cli_i, &u, &q, mgt_param.cli_timeout);
VCLI_SetResult(cli, u);
VCLI_Out(cli, "%s", q);
free(q);
@@ -192,7 +192,7 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) {
int i, j;
va_list ap;
unsigned u;
- char buf[params->cli_buffer], *p;
+ char buf[mgt_param.cli_buffer], *p;
if (resp != NULL)
*resp = NULL;
@@ -219,7 +219,7 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) {
return (CLIS_COMMS);
}
- (void)VCLI_ReadResult(cli_i, &u, resp, params->cli_timeout);
+ (void)VCLI_ReadResult(cli_i, &u, resp, mgt_param.cli_timeout);
if (status != NULL)
*status = u;
if (u == CLIS_COMMS)
@@ -316,7 +316,7 @@ static void
mgt_cli_cb_before(const struct cli *cli)
{
- if (params->syslog_cli_traffic)
+ if (mgt_param.syslog_cli_traffic)
syslog(LOG_NOTICE, "CLI %s Rd %s", cli->ident, cli->cmd);
}
@@ -324,7 +324,7 @@ static void
mgt_cli_cb_after(const struct cli *cli)
{
- if (params->syslog_cli_traffic)
+ if (mgt_param.syslog_cli_traffic)
syslog(LOG_NOTICE, "CLI %s Wr %03u %s",
cli->ident, cli->result, VSB_data(cli->sb));
}
@@ -335,7 +335,7 @@ static void
mgt_cli_init_cls(void)
{
- cls = VCLS_New(mgt_cli_cb_before, mgt_cli_cb_after, params->cli_buffer);
+ cls = VCLS_New(mgt_cli_cb_before, mgt_cli_cb_after, mgt_param.cli_buffer);
AN(cls);
AZ(VCLS_AddFunc(cls, MCF_NOAUTH, cli_auth));
AZ(VCLS_AddFunc(cls, MCF_AUTH, cli_proto));
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index e2eb16b..20456d7 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -51,7 +51,7 @@
#include "mgt_cli.h"
#define MAGIC_INIT_STRING "\001"
-struct params master;
+struct params mgt_param;
static int nparspec;
static struct parspec const ** parspec;
static int margin;
@@ -262,7 +262,7 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
if (!strcmp(arg, MAGIC_INIT_STRING)) {
pw = getpwnam("nobody");
if (pw == NULL) {
- master.uid = getuid();
+ mgt_param.uid = getuid();
return;
}
} else
@@ -272,19 +272,19 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg)
VCLI_SetResult(cli, CLIS_PARAM);
return;
}
- REPLACE(master.user, pw->pw_name);
- master.uid = pw->pw_uid;
- master.gid = pw->pw_gid;
+ REPLACE(mgt_param.user, pw->pw_name);
+ mgt_param.uid = pw->pw_uid;
+ mgt_param.gid = pw->pw_gid;
/* set group to user's primary group */
if ((gr = getgrgid(pw->pw_gid)) != NULL &&
(gr = getgrnam(gr->gr_name)) != NULL &&
gr->gr_gid == pw->pw_gid)
- REPLACE(master.group, gr->gr_name);
- } else if (master.user) {
- VCLI_Out(cli, "%s (%d)", master.user, (int)master.uid);
+ REPLACE(mgt_param.group, gr->gr_name);
+ } else if (mgt_param.user) {
+ VCLI_Out(cli, "%s (%d)", mgt_param.user, (int)mgt_param.uid);
} else {
- VCLI_Out(cli, "%d", (int)master.uid);
+ VCLI_Out(cli, "%d", (int)mgt_param.uid);
}
}
@@ -303,8 +303,8 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
gr = getgrnam("nogroup");
if (gr == NULL) {
/* Only replace if tweak_user didn't */
- if (master.gid == 0)
- master.gid = getgid();
+ if (mgt_param.gid == 0)
+ mgt_param.gid = getgid();
return;
}
} else
@@ -314,12 +314,12 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg)
VCLI_SetResult(cli, CLIS_PARAM);
return;
}
- REPLACE(master.group, gr->gr_name);
- master.gid = gr->gr_gid;
- } else if (master.group) {
- VCLI_Out(cli, "%s (%d)", master.group, (int)master.gid);
+ REPLACE(mgt_param.group, gr->gr_name);
+ mgt_param.gid = gr->gr_gid;
+ } else if (mgt_param.group) {
+ VCLI_Out(cli, "%s (%d)", mgt_param.group, (int)mgt_param.gid);
} else {
- VCLI_Out(cli, "%d", (int)master.gid);
+ VCLI_Out(cli, "%d", (int)mgt_param.gid);
}
}
@@ -350,7 +350,7 @@ tweak_listen_address(struct cli *cli, const struct parspec *par,
(void)par;
if (arg == NULL) {
- VCLI_Quote(cli, master.listen_address);
+ VCLI_Quote(cli, mgt_param.listen_address);
return;
}
@@ -401,7 +401,7 @@ tweak_listen_address(struct cli *cli, const struct parspec *par,
return;
}
- REPLACE(master.listen_address, arg);
+ REPLACE(mgt_param.listen_address, arg);
clean_listen_sock_head(&heritage.socks);
heritage.nsocks = 0;
@@ -452,9 +452,9 @@ tweak_diag_bitmap(struct cli *cli, const struct parspec *par, const char *arg)
(void)par;
if (arg != NULL) {
u = strtoul(arg, NULL, 0);
- master.diag_bitmap = u;
+ mgt_param.diag_bitmap = u;
} else {
- VCLI_Out(cli, "0x%x", master.diag_bitmap);
+ VCLI_Out(cli, "0x%x", mgt_param.diag_bitmap);
}
}
@@ -500,7 +500,7 @@ static const struct parspec input_parspec[] = {
"The unprivileged group to run as.",
MUST_RESTART,
MAGIC_INIT_STRING },
- { "default_ttl", tweak_timeout_double, &master.default_ttl,
+ { "default_ttl", tweak_timeout_double, &mgt_param.default_ttl,
0, UINT_MAX,
"The TTL assigned to objects if neither the backend nor "
"the VCL code assigns one.\n"
@@ -510,7 +510,7 @@ static const struct parspec input_parspec[] = {
"flush of the cache use \"ban.url .\"",
0,
"120", "seconds" },
- { "sess_workspace", tweak_uint, &master.sess_workspace, 1024, UINT_MAX,
+ { "sess_workspace", tweak_uint, &mgt_param.sess_workspace, 1024, UINT_MAX,
"Bytes of HTTP protocol workspace allocated for sessions. "
"This space must be big enough for the entire HTTP protocol "
"header and any edits done to it in the VCL code.\n"
@@ -518,13 +518,13 @@ static const struct parspec input_parspec[] = {
DELAYED_EFFECT,
"65536",
"bytes" },
- { "http_req_hdr_len", tweak_uint, &master.http_req_hdr_len,
+ { "http_req_hdr_len", tweak_uint, &mgt_param.http_req_hdr_len,
40, UINT_MAX,
"Maximum length of any HTTP client request header we will "
"allow. The limit is inclusive its continuation lines.\n",
0,
"8192", "bytes" },
- { "http_req_size", tweak_uint, &master.http_req_size,
+ { "http_req_size", tweak_uint, &mgt_param.http_req_size,
256, UINT_MAX,
"Maximum number of bytes of HTTP client request we will deal "
"with. This is a limit on all bytes up to the double blank "
@@ -534,13 +534,13 @@ static const struct parspec input_parspec[] = {
"how much of that the request is allowed to take up.",
0,
"32768", "bytes" },
- { "http_resp_hdr_len", tweak_uint, &master.http_resp_hdr_len,
+ { "http_resp_hdr_len", tweak_uint, &mgt_param.http_resp_hdr_len,
40, UINT_MAX,
"Maximum length of any HTTP backend response header we will "
"allow. The limit is inclusive its continuation lines.\n",
0,
"8192", "bytes" },
- { "http_resp_size", tweak_uint, &master.http_resp_size,
+ { "http_resp_size", tweak_uint, &mgt_param.http_resp_size,
256, UINT_MAX,
"Maximum number of bytes of HTTP backend resonse we will deal "
"with. This is a limit on all bytes up to the double blank "
@@ -550,7 +550,7 @@ static const struct parspec input_parspec[] = {
"how much of that the request is allowed to take up.",
0,
"32768", "bytes" },
- { "http_max_hdr", tweak_uint, &master.http_max_hdr, 32, 65535,
+ { "http_max_hdr", tweak_uint, &mgt_param.http_max_hdr, 32, 65535,
"Maximum number of HTTP headers we will deal with in "
"client request or backend reponses. "
"Note that the first line occupies five header fields.\n"
@@ -558,7 +558,7 @@ static const struct parspec input_parspec[] = {
"objects allocate exact space for the headers they store.\n",
0,
"64", "header lines" },
- { "shm_workspace", tweak_uint, &master.shm_workspace, 4096, UINT_MAX,
+ { "shm_workspace", tweak_uint, &mgt_param.shm_workspace, 4096, UINT_MAX,
"Bytes of shmlog workspace allocated for worker threads. "
"If too big, it wastes some ram, if too small it causes "
"needless flushes of the SHM workspace.\n"
@@ -567,12 +567,12 @@ static const struct parspec input_parspec[] = {
"Minimum is 4096 bytes.",
DELAYED_EFFECT,
"8192", "bytes" },
- { "shm_reclen", tweak_uint, &master.shm_reclen, 16, 65535,
+ { "shm_reclen", tweak_uint, &mgt_param.shm_reclen, 16, 65535,
"Maximum number of bytes in SHM log record.\n"
"Maximum is 65535 bytes.",
0,
"255", "bytes" },
- { "default_grace", tweak_timeout_double, &master.default_grace,
+ { "default_grace", tweak_timeout_double, &mgt_param.default_grace,
0, UINT_MAX,
"Default grace period. We will deliver an object "
"this long after it has expired, provided another thread "
@@ -581,7 +581,7 @@ static const struct parspec input_parspec[] = {
"made until they are fetched from the backend again.\n",
DELAYED_EFFECT,
"10", "seconds" },
- { "default_keep", tweak_timeout_double, &master.default_keep,
+ { "default_keep", tweak_timeout_double, &mgt_param.default_keep,
0, UINT_MAX,
"Default keep period. We will keep a useless object "
"around this long, making it available for conditional "
@@ -590,49 +590,49 @@ static const struct parspec input_parspec[] = {
"cache at the end of ttl+grace+keep.",
DELAYED_EFFECT,
"0", "seconds" },
- { "sess_timeout", tweak_timeout, &master.sess_timeout, 0, 0,
+ { "sess_timeout", tweak_timeout, &mgt_param.sess_timeout, 0, 0,
"Idle timeout for persistent sessions. "
"If a HTTP request has not been received in this many "
"seconds, the session is closed.",
0,
"5", "seconds" },
- { "expiry_sleep", tweak_timeout_double, &master.expiry_sleep, 0, 60,
+ { "expiry_sleep", tweak_timeout_double, &mgt_param.expiry_sleep, 0, 60,
"How long the expiry thread sleeps when there is nothing "
"for it to do.\n",
0,
"1", "seconds" },
- { "pipe_timeout", tweak_timeout, &master.pipe_timeout, 0, 0,
+ { "pipe_timeout", tweak_timeout, &mgt_param.pipe_timeout, 0, 0,
"Idle timeout for PIPE sessions. "
"If nothing have been received in either direction for "
"this many seconds, the session is closed.\n",
0,
"60", "seconds" },
- { "send_timeout", tweak_timeout, &master.send_timeout, 0, 0,
+ { "send_timeout", tweak_timeout, &mgt_param.send_timeout, 0, 0,
"Send timeout for client connections. "
"If the HTTP response hasn't been transmitted in this many\n"
"seconds the session is closed. \n"
"See setsockopt(2) under SO_SNDTIMEO for more information.",
DELAYED_EFFECT,
"600", "seconds" },
- { "idle_send_timeout", tweak_timeout, &master.idle_send_timeout, 0, 0,
+ { "idle_send_timeout", tweak_timeout, &mgt_param.idle_send_timeout, 0, 0,
"Time to wait with no data sent. "
"If no data has been transmitted in this many\n"
"seconds the session is closed. \n"
"See setsockopt(2) under SO_SNDTIMEO for more information.",
DELAYED_EFFECT,
"60", "seconds" },
- { "auto_restart", tweak_bool, &master.auto_restart, 0, 0,
+ { "auto_restart", tweak_bool, &mgt_param.auto_restart, 0, 0,
"Restart child process automatically if it dies.\n",
0,
"on", "bool" },
{ "nuke_limit",
- tweak_uint, &master.nuke_limit, 0, UINT_MAX,
+ tweak_uint, &mgt_param.nuke_limit, 0, UINT_MAX,
"Maximum number of objects we attempt to nuke in order"
"to make space for a object body.",
EXPERIMENTAL,
"50", "allocations" },
{ "fetch_chunksize",
- tweak_uint, &master.fetch_chunksize, 4, UINT_MAX / 1024.,
+ tweak_uint, &mgt_param.fetch_chunksize, 4, UINT_MAX / 1024.,
"The default chunksize used by fetcher. "
"This should be bigger than the majority of objects with "
"short TTLs.\n"
@@ -641,7 +641,7 @@ static const struct parspec input_parspec[] = {
EXPERIMENTAL,
"128", "kilobytes" },
{ "fetch_maxchunksize",
- tweak_uint, &master.fetch_maxchunksize, 64, UINT_MAX / 1024.,
+ tweak_uint, &mgt_param.fetch_maxchunksize, 64, UINT_MAX / 1024.,
"The maximum chunksize we attempt to allocate from storage. "
"Making this too large may cause delays and storage "
"fragmentation.\n",
@@ -649,12 +649,12 @@ static const struct parspec input_parspec[] = {
"262144", "kilobytes" },
#ifdef SENDFILE_WORKS
{ "sendfile_threshold",
- tweak_uint, &master.sendfile_threshold, 0, UINT_MAX,
+ tweak_uint, &mgt_param.sendfile_threshold, 0, UINT_MAX,
"The minimum size of objects transmitted with sendfile.",
EXPERIMENTAL,
"-1", "bytes" },
#endif /* SENDFILE_WORKS */
- { "vcl_trace", tweak_bool, &master.vcl_trace, 0, 0,
+ { "vcl_trace", tweak_bool, &mgt_param.vcl_trace, 0, 0,
"Trace VCL execution in the shmlog.\n"
"Enabling this will allow you to see the path each "
"request has taken through the VCL program.\n"
@@ -668,22 +668,22 @@ static const struct parspec input_parspec[] = {
"Possible formats: host, host:port, :port",
MUST_RESTART,
":80" },
- { "listen_depth", tweak_uint, &master.listen_depth, 0, UINT_MAX,
+ { "listen_depth", tweak_uint, &mgt_param.listen_depth, 0, UINT_MAX,
"Listen queue depth.",
MUST_RESTART,
"1024", "connections" },
- { "cli_timeout", tweak_timeout, &master.cli_timeout, 0, 0,
+ { "cli_timeout", tweak_timeout, &mgt_param.cli_timeout, 0, 0,
"Timeout for the childs replies to CLI requests from "
- "the master.",
+ "the mgt_param.",
0,
"10", "seconds" },
- { "ping_interval", tweak_uint, &master.ping_interval, 0, UINT_MAX,
+ { "ping_interval", tweak_uint, &mgt_param.ping_interval, 0, UINT_MAX,
"Interval between pings from parent to child.\n"
"Zero will disable pinging entirely, which makes "
"it possible to attach a debugger to the child.",
MUST_RESTART,
"3", "seconds" },
- { "lru_interval", tweak_timeout, &master.lru_timeout, 0, 0,
+ { "lru_interval", tweak_timeout, &mgt_param.lru_timeout, 0, 0,
"Grace period before object moves on LRU list.\n"
"Objects are only moved to the front of the LRU "
"list if they have not been moved there already inside "
@@ -698,14 +698,14 @@ static const struct parspec input_parspec[] = {
"and %o will be replaced with the output file name.",
MUST_RELOAD,
VCC_CC , NULL },
- { "max_restarts", tweak_uint, &master.max_restarts, 0, UINT_MAX,
+ { "max_restarts", tweak_uint, &mgt_param.max_restarts, 0, UINT_MAX,
"Upper limit on how many times a request can restart."
"\nBe aware that restarts are likely to cause a hit against "
"the backend, so don't increase thoughtlessly.\n",
0,
"4", "restarts" },
{ "esi_syntax",
- tweak_uint, &master.esi_syntax, 0, UINT_MAX,
+ tweak_uint, &mgt_param.esi_syntax, 0, UINT_MAX,
"Bitmap controlling ESI parsing code:\n"
" 0x00000001 - Don't check if it looks like XML\n"
" 0x00000002 - Ignore non-esi elements\n"
@@ -715,12 +715,12 @@ static const struct parspec input_parspec[] = {
0,
"0", "bitmap" },
{ "max_esi_depth",
- tweak_uint, &master.max_esi_depth, 0, UINT_MAX,
+ tweak_uint, &mgt_param.max_esi_depth, 0, UINT_MAX,
"Maximum depth of esi:include processing.\n",
0,
"5", "levels" },
{ "connect_timeout", tweak_timeout_double,
- &master.connect_timeout,0, UINT_MAX,
+ &mgt_param.connect_timeout,0, UINT_MAX,
"Default connection timeout for backend connections. "
"We only try to connect to the backend for this many "
"seconds before giving up. "
@@ -729,7 +729,7 @@ static const struct parspec input_parspec[] = {
0,
"0.7", "s" },
{ "first_byte_timeout", tweak_timeout_double,
- &master.first_byte_timeout,0, UINT_MAX,
+ &mgt_param.first_byte_timeout,0, UINT_MAX,
"Default timeout for receiving first byte from backend. "
"We only wait for this many seconds for the first "
"byte before giving up. A value of 0 means it will never time "
@@ -739,7 +739,7 @@ static const struct parspec input_parspec[] = {
0,
"60", "s" },
{ "between_bytes_timeout", tweak_timeout_double,
- &master.between_bytes_timeout,0, UINT_MAX,
+ &mgt_param.between_bytes_timeout,0, UINT_MAX,
"Default timeout between bytes when receiving data from "
"backend. "
"We only wait for this many seconds between bytes "
@@ -749,7 +749,7 @@ static const struct parspec input_parspec[] = {
0,
"60", "s" },
{ "acceptor_sleep_max", tweak_timeout_double,
- &master.acceptor_sleep_max, 0, 10,
+ &mgt_param.acceptor_sleep_max, 0, 10,
"If we run out of resources, such as file descriptors or "
"worker threads, the acceptor will sleep between accepts.\n"
"This parameter limits how long it can sleep between "
@@ -757,7 +757,7 @@ static const struct parspec input_parspec[] = {
EXPERIMENTAL,
"0.050", "s" },
{ "acceptor_sleep_incr", tweak_timeout_double,
- &master.acceptor_sleep_incr, 0, 1,
+ &mgt_param.acceptor_sleep_incr, 0, 1,
"If we run out of resources, such as file descriptors or "
"worker threads, the acceptor will sleep between accepts.\n"
"This parameter control how much longer we sleep, each time "
@@ -765,25 +765,25 @@ static const struct parspec input_parspec[] = {
EXPERIMENTAL,
"0.001", "s" },
{ "acceptor_sleep_decay", tweak_generic_double,
- &master.acceptor_sleep_decay, 0, 1,
+ &mgt_param.acceptor_sleep_decay, 0, 1,
"If we run out of resources, such as file descriptors or "
"worker threads, the acceptor will sleep between accepts.\n"
"This parameter (multiplicatively) reduce the sleep duration "
"for each succesfull accept. (ie: 0.9 = reduce by 10%)",
EXPERIMENTAL,
"0.900", "" },
- { "clock_skew", tweak_uint, &master.clock_skew, 0, UINT_MAX,
+ { "clock_skew", tweak_uint, &mgt_param.clock_skew, 0, UINT_MAX,
"How much clockskew we are willing to accept between the "
"backend and our own clock.",
0,
"10", "s" },
- { "prefer_ipv6", tweak_bool, &master.prefer_ipv6, 0, 0,
+ { "prefer_ipv6", tweak_bool, &mgt_param.prefer_ipv6, 0, 0,
"Prefer IPv6 address when connecting to backends which "
"have both IPv4 and IPv6 addresses.",
0,
"off", "bool" },
{ "session_max", tweak_uint,
- &master.max_sess, 1000, UINT_MAX,
+ &mgt_param.max_sess, 1000, UINT_MAX,
"Maximum number of sessions we will allocate from one pool "
"before just dropping connections.\n"
"This is mostly an anti-DoS measure, and setting it plenty "
@@ -792,7 +792,7 @@ static const struct parspec input_parspec[] = {
0,
"100000", "sessions" },
{ "session_linger", tweak_uint,
- &master.session_linger,0, UINT_MAX,
+ &mgt_param.session_linger,0, UINT_MAX,
"How long time the workerthread lingers on the session "
"to see if a new request appears right away.\n"
"If sessions are reused, as much as half of all reuses "
@@ -803,18 +803,18 @@ static const struct parspec input_parspec[] = {
"more sessions take a detour around the waiter.",
EXPERIMENTAL,
"50", "ms" },
- { "cli_buffer", tweak_uint, &master.cli_buffer, 4096, UINT_MAX,
+ { "cli_buffer", tweak_uint, &mgt_param.cli_buffer, 4096, UINT_MAX,
"Size of buffer for CLI input."
"\nYou may need to increase this if you have big VCL files "
"and use the vcl.inline CLI command.\n"
"NB: Must be specified with -p to have effect.\n",
0,
"8192", "bytes" },
- { "log_hashstring", tweak_bool, &master.log_hash, 0, 0,
+ { "log_hashstring", tweak_bool, &mgt_param.log_hash, 0, 0,
"Log the hash string components to shared memory log.\n",
0,
"on", "bool" },
- { "log_local_address", tweak_bool, &master.log_local_addr, 0, 0,
+ { "log_local_address", tweak_bool, &mgt_param.log_local_addr, 0, 0,
"Log the local address on the TCP connection in the "
"SessionOpen shared memory record.\n",
0,
@@ -846,16 +846,16 @@ static const struct parspec input_parspec[] = {
"Use 0x notation and do the bitor in your head :-)\n",
0,
"0", "bitmap" },
- { "ban_dups", tweak_bool, &master.ban_dups, 0, 0,
+ { "ban_dups", tweak_bool, &mgt_param.ban_dups, 0, 0,
"Detect and eliminate duplicate bans.\n",
0,
"on", "bool" },
- { "syslog_cli_traffic", tweak_bool, &master.syslog_cli_traffic, 0, 0,
+ { "syslog_cli_traffic", tweak_bool, &mgt_param.syslog_cli_traffic, 0, 0,
"Log all CLI traffic to syslog(LOG_INFO).\n",
0,
"on", "bool" },
{ "ban_lurker_sleep", tweak_timeout_double,
- &master.ban_lurker_sleep, 0, UINT_MAX,
+ &mgt_param.ban_lurker_sleep, 0, UINT_MAX,
"How long time does the ban lurker thread sleeps between "
"successful attempts to push the last item up the ban "
" list. It always sleeps a second when nothing can be done.\n"
@@ -863,17 +863,17 @@ static const struct parspec input_parspec[] = {
0,
"0.01", "s" },
{ "saintmode_threshold", tweak_uint,
- &master.saintmode_threshold, 0, UINT_MAX,
+ &mgt_param.saintmode_threshold, 0, UINT_MAX,
"The maximum number of objects held off by saint mode before "
"no further will be made to the backend until one times out. "
"A value of 0 disables saintmode.",
EXPERIMENTAL,
"10", "objects" },
- { "http_range_support", tweak_bool, &master.http_range_support, 0, 0,
+ { "http_range_support", tweak_bool, &mgt_param.http_range_support, 0, 0,
"Enable support for HTTP Range headers.\n",
EXPERIMENTAL,
"on", "bool" },
- { "http_gzip_support", tweak_bool, &master.http_gzip_support, 0, 0,
+ { "http_gzip_support", tweak_bool, &mgt_param.http_gzip_support, 0, 0,
"Enable gzip support. When enabled Varnish will compress "
"uncompressed objects before they are stored in the cache. "
"If a client does not support gzip encoding Varnish will "
@@ -887,7 +887,7 @@ static const struct parspec input_parspec[] = {
"Varnish reference.",
EXPERIMENTAL,
"on", "bool" },
- { "gzip_tmp_space", tweak_uint, &master.gzip_tmp_space, 0, 2,
+ { "gzip_tmp_space", tweak_uint, &mgt_param.gzip_tmp_space, 0, 2,
"Where temporary space for gzip/gunzip is allocated:\n"
" 0 - malloc\n"
" 2 - thread workspace\n"
@@ -897,21 +897,21 @@ static const struct parspec input_parspec[] = {
" needs 32+KB of workspace (64+KB if ESI processing).",
EXPERIMENTAL,
"0", "" },
- { "gzip_level", tweak_uint, &master.gzip_level, 0, 9,
+ { "gzip_level", tweak_uint, &mgt_param.gzip_level, 0, 9,
"Gzip compression level: 0=debug, 1=fast, 9=best",
0,
"6", ""},
- { "gzip_window", tweak_uint, &master.gzip_window, 8, 15,
+ { "gzip_window", tweak_uint, &mgt_param.gzip_window, 8, 15,
"Gzip window size 8=least, 15=most compression.\n"
"Memory impact is 8=1k, 9=2k, ... 15=128k.",
0,
"15", ""},
- { "gzip_memlevel", tweak_uint, &master.gzip_memlevel, 1, 9,
+ { "gzip_memlevel", tweak_uint, &mgt_param.gzip_memlevel, 1, 9,
"Gzip memory level 1=slow/least, 9=fast/most compression.\n"
"Memory impact is 1=1k, 2=2k, ... 9=256k.",
0,
"8", ""},
- { "gzip_stack_buffer", tweak_uint, &master.gzip_stack_buffer,
+ { "gzip_stack_buffer", tweak_uint, &mgt_param.gzip_stack_buffer,
2048, UINT_MAX,
"Size of stack buffer used for gzip processing.\n"
"The stack buffers are used for in-transit data,"
@@ -922,13 +922,13 @@ static const struct parspec input_parspec[] = {
EXPERIMENTAL,
"32768", "Bytes" },
{ "shortlived", tweak_timeout_double,
- &master.shortlived, 0, UINT_MAX,
+ &mgt_param.shortlived, 0, UINT_MAX,
"Objects created with TTL shorter than this are always "
"put in transient storage.\n",
0,
"10.0", "s" },
{ "critbit_cooloff", tweak_timeout_double,
- &master.critbit_cooloff, 60, 254,
+ &mgt_param.critbit_cooloff, 60, 254,
"How long time the critbit hasher keeps deleted objheads "
"on the cooloff list.\n",
WIZARD,
@@ -959,7 +959,7 @@ static const struct parspec input_parspec[] = {
{ "pcre_match_limit", tweak_uint,
- &master.vre_limits.match,
+ &mgt_param.vre_limits.match,
1, UINT_MAX,
"The limit for the number of internal matching function"
" calls in a pcre_exec() execution.",
@@ -967,7 +967,7 @@ static const struct parspec input_parspec[] = {
"10000", ""},
{ "pcre_match_limit_recursion", tweak_uint,
- &master.vre_limits.match_recursion,
+ &mgt_param.vre_limits.match_recursion,
1, UINT_MAX,
"The limit for the number of internal matching function"
" recursions in a pcre_exec() execution.",
@@ -1062,37 +1062,31 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv)
/*--------------------------------------------------------------------*/
void
-MCF_ParamSync(void)
-{
- if (params != &master)
- *params = master;
-}
-
-/*--------------------------------------------------------------------*/
-
-void
MCF_ParamSet(struct cli *cli, const char *param, const char *val)
{
const struct parspec *pp;
pp = mcf_findpar(param);
- if (pp != NULL) {
- pp->func(cli, pp, val);
- if (cli->result != CLIS_OK) {
- VCLI_Out(cli, "(attempting to set param %s to %s)\n",
- pp->name, val);
- } else if (child_pid >= 0 && pp->flags & MUST_RESTART) {
- VCLI_Out(cli, "Change will take effect"
- " when child is restarted");
- } else if (pp->flags & MUST_RELOAD) {
- VCLI_Out(cli, "Change will take effect"
- " when VCL script is reloaded");
- }
- MCF_ParamSync();
+ if (pp == NULL) {
+ VCLI_SetResult(cli, CLIS_PARAM);
+ VCLI_Out(cli, "Unknown parameter \"%s\".", param);
return;
}
- VCLI_SetResult(cli, CLIS_PARAM);
- VCLI_Out(cli, "Unknown parameter \"%s\".", param);
+ pp->func(cli, pp, val);
+
+ if (cli->result == CLIS_OK && params != NULL)
+ *params = mgt_param;
+
+ if (cli->result != CLIS_OK) {
+ VCLI_Out(cli, "(attempting to set param %s to %s)\n",
+ pp->name, val);
+ } else if (child_pid >= 0 && pp->flags & MUST_RESTART) {
+ VCLI_Out(cli, "Change will take effect"
+ " when child is restarted");
+ } else if (pp->flags & MUST_RELOAD) {
+ VCLI_Out(cli, "Change will take effect"
+ " when VCL script is reloaded");
+ }
}
@@ -1173,8 +1167,6 @@ MCF_ParamInit(struct cli *cli)
/* XXX: We do this twice, to get past any interdependencies */
MCF_SetDefaults(NULL);
MCF_SetDefaults(cli);
-
- params = &master;
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c
index 978e60a..94459b4 100644
--- a/bin/varnishd/mgt/mgt_pool.c
+++ b/bin/varnishd/mgt/mgt_pool.c
@@ -59,8 +59,8 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par,
const char *arg)
{
- tweak_generic_uint(cli, &master.wthread_min, arg,
- (unsigned)par->min, master.wthread_max);
+ tweak_generic_uint(cli, &mgt_param.wthread_min, arg,
+ (unsigned)par->min, mgt_param.wthread_max);
}
/*--------------------------------------------------------------------
@@ -86,7 +86,7 @@ tweak_stack_size(struct cli *cli, const struct parspec *par,
arg = buf;
}
- tweak_generic_uint(cli, &master.wthread_stacksize, arg,
+ tweak_generic_uint(cli, &mgt_param.wthread_stacksize, arg,
low, (uint)par->max);
}
@@ -98,14 +98,14 @@ tweak_thread_pool_max(struct cli *cli, const struct parspec *par,
{
(void)par;
- tweak_generic_uint(cli, &master.wthread_max, arg,
- master.wthread_min, UINT_MAX);
+ tweak_generic_uint(cli, &mgt_param.wthread_max, arg,
+ mgt_param.wthread_min, UINT_MAX);
}
/*--------------------------------------------------------------------*/
const struct parspec WRK_parspec[] = {
- { "thread_pools", tweak_uint, &master.wthread_pools, 1, UINT_MAX,
+ { "thread_pools", tweak_uint, &mgt_param.wthread_pools, 1, UINT_MAX,
"Number of worker thread pools.\n"
"\n"
"Increasing number of worker pools decreases lock "
@@ -135,7 +135,7 @@ const struct parspec WRK_parspec[] = {
"Minimum is 2 threads.",
EXPERIMENTAL | DELAYED_EFFECT,
"5", "threads" },
- { "thread_pool_timeout", tweak_timeout, &master.wthread_timeout, 1, 0,
+ { "thread_pool_timeout", tweak_timeout, &mgt_param.wthread_timeout, 1, 0,
"Thread idle threshold.\n"
"\n"
"Threads in excess of thread_pool_min, which have been idle "
@@ -145,7 +145,7 @@ const struct parspec WRK_parspec[] = {
EXPERIMENTAL | DELAYED_EFFECT,
"300", "seconds" },
{ "thread_pool_purge_delay",
- tweak_timeout, &master.wthread_purge_delay, 100, 0,
+ tweak_timeout, &mgt_param.wthread_purge_delay, 100, 0,
"Wait this long between purging threads.\n"
"\n"
"This controls the decay of thread pools when idle(-ish).\n"
@@ -154,7 +154,7 @@ const struct parspec WRK_parspec[] = {
EXPERIMENTAL | DELAYED_EFFECT,
"1000", "milliseconds" },
{ "thread_pool_add_threshold",
- tweak_uint, &master.wthread_add_threshold, 0, UINT_MAX,
+ tweak_uint, &mgt_param.wthread_add_threshold, 0, UINT_MAX,
"Overflow threshold for worker thread creation.\n"
"\n"
"Setting this too low, will result in excess worker threads, "
@@ -164,7 +164,7 @@ const struct parspec WRK_parspec[] = {
EXPERIMENTAL,
"2", "requests" },
{ "thread_pool_add_delay",
- tweak_timeout, &master.wthread_add_delay, 0, UINT_MAX,
+ tweak_timeout, &mgt_param.wthread_add_delay, 0, UINT_MAX,
"Wait at least this long between creating threads.\n"
"\n"
"Setting this too long results in insuffient worker threads.\n"
@@ -174,7 +174,7 @@ const struct parspec WRK_parspec[] = {
0,
"2", "milliseconds" },
{ "thread_pool_fail_delay",
- tweak_timeout, &master.wthread_fail_delay, 100, UINT_MAX,
+ tweak_timeout, &mgt_param.wthread_fail_delay, 100, UINT_MAX,
"Wait at least this long after a failed thread creation "
"before trying to create another thread.\n"
"\n"
@@ -192,7 +192,7 @@ const struct parspec WRK_parspec[] = {
EXPERIMENTAL,
"200", "milliseconds" },
{ "thread_stats_rate",
- tweak_uint, &master.wthread_stats_rate, 0, UINT_MAX,
+ tweak_uint, &mgt_param.wthread_stats_rate, 0, UINT_MAX,
"Worker threads accumulate statistics, and dump these into "
"the global stats counters if the lock is free when they "
"finish a request.\n"
@@ -201,14 +201,14 @@ const struct parspec WRK_parspec[] = {
"its accumulated stats into the global counters.\n",
EXPERIMENTAL,
"10", "requests" },
- { "queue_max", tweak_uint, &master.queue_max, 0, UINT_MAX,
+ { "queue_max", tweak_uint, &mgt_param.queue_max, 0, UINT_MAX,
"Percentage permitted queue length.\n"
"\n"
"This sets the ratio of queued requests to worker threads, "
"above which sessions will be dropped instead of queued.\n",
EXPERIMENTAL,
"100", "%" },
- { "rush_exponent", tweak_uint, &master.rush_exponent, 2, UINT_MAX,
+ { "rush_exponent", tweak_uint, &mgt_param.rush_exponent, 2, UINT_MAX,
"How many parked request we start for each completed "
"request on the object.\n"
"NB: Even with the implict delay of delivery, "
@@ -217,13 +217,13 @@ const struct parspec WRK_parspec[] = {
EXPERIMENTAL,
"3", "requests per request" },
{ "thread_pool_stack",
- tweak_stack_size, &master.wthread_stacksize, 0, UINT_MAX,
+ tweak_stack_size, &mgt_param.wthread_stacksize, 0, UINT_MAX,
"Worker thread stack size.\n"
"On 32bit systems you may need to tweak this down to fit "
"many threads into the limited address space.\n",
EXPERIMENTAL,
"-1", "bytes" },
- { "thread_pool_workspace", tweak_uint, &master.wthread_workspace,
+ { "thread_pool_workspace", tweak_uint, &mgt_param.wthread_workspace,
1024, UINT_MAX,
"Bytes of HTTP protocol workspace allocated for worker "
"threads. "
diff --git a/bin/varnishd/mgt/mgt_sandbox.c b/bin/varnishd/mgt/mgt_sandbox.c
index b01d243..e5fe99c 100644
--- a/bin/varnishd/mgt/mgt_sandbox.c
+++ b/bin/varnishd/mgt/mgt_sandbox.c
@@ -68,8 +68,8 @@ mgt_sandbox(void)
mgt_sandbox_solaris_privsep();
#else
if (geteuid() == 0) {
- XXXAZ(setgid(params->gid));
- XXXAZ(setuid(params->uid));
+ XXXAZ(setgid(mgt_param.gid));
+ XXXAZ(setuid(mgt_param.uid));
} else {
REPORT0(LOG_INFO, "Not running as root, no priv-sep");
}
diff --git a/bin/varnishd/mgt/mgt_sandbox_solaris.c b/bin/varnishd/mgt/mgt_sandbox_solaris.c
index becaa2e..8c26d69 100644
--- a/bin/varnishd/mgt/mgt_sandbox_solaris.c
+++ b/bin/varnishd/mgt/mgt_sandbox_solaris.c
@@ -158,10 +158,10 @@ void
mgt_sandbox_solaris_privsep(void)
{
if (priv_ineffect(PRIV_PROC_SETID)) {
- if (getgid() != params->gid)
- XXXAZ(setgid(params->gid));
- if (getuid() != params->uid)
- XXXAZ(setuid(params->uid));
+ if (getgid() != mgt_param.gid)
+ XXXAZ(setgid(mgt_param.gid));
+ if (getuid() != mgt_param.uid)
+ XXXAZ(setuid(mgt_param.uid));
} else {
REPORT(LOG_INFO, "Privilege %s missing, will not change uid/gid",
PRIV_PROC_SETID);
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index 630865d..37083df 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -229,7 +229,6 @@ void
mgt_SHM_Init(const char *l_arg)
{
int i, fill;
- struct params *pp;
const char *q;
uintmax_t size, s1, s2, ps;
char **av, **ap;
@@ -321,10 +320,10 @@ mgt_SHM_Init(const char *l_arg)
VSC_CLASS, VSC_TYPE_MAIN, "");
AN(VSC_C_main);
- pp = VSM_Alloc(sizeof *pp, VSM_CLASS_PARAM, "", "");
- AN(pp);
- *pp = *params;
- params = pp;
+ /* XXX: We need to zero params if we dealloc/clean/wash */
+ params = VSM_Alloc(sizeof *params, VSM_CLASS_PARAM, "", "");
+ AN(params);
+ *params = mgt_param;
vsl_log_start = VSM_Alloc(s1, VSL_CLASS, "", "");
AN(vsl_log_start);
diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c
index e0ba759..6ae1842 100644
--- a/bin/varnishd/varnishd.c
+++ b/bin/varnishd/varnishd.c
@@ -64,7 +64,6 @@
#endif
struct heritage heritage;
-volatile struct params *params;
unsigned d_flag = 0;
pid_t mgt_pid;
struct vev_base *mgt_evb;
@@ -190,17 +189,17 @@ tackle_warg(const char *argv)
u = arg_ul(av[1]);
if (u < 1)
usage();
- params->wthread_max = params->wthread_min = u;
+ mgt_param.wthread_max = mgt_param.wthread_min = u;
if (av[2] != NULL) {
u = arg_ul(av[2]);
- if (u < params->wthread_min)
+ if (u < mgt_param.wthread_min)
usage();
- params->wthread_max = u;
+ mgt_param.wthread_max = u;
if (av[3] != NULL) {
u = arg_ul(av[3]);
- params->wthread_timeout = u;
+ mgt_param.wthread_timeout = u;
}
}
VAV_Free(av);
diff --git a/bin/varnishd/vparam.h b/bin/varnishd/vparam.h
index 2a83de1..2d4a97f 100644
--- a/bin/varnishd/vparam.h
+++ b/bin/varnishd/vparam.h
@@ -55,7 +55,5 @@ void tweak_uint(struct cli *cli, const struct parspec *par, const char *arg);
void tweak_timeout(struct cli *cli,
const struct parspec *par, const char *arg);
-extern struct params master;
-
/* mgt_pool.c */
extern const struct parspec WRK_parspec[];
More information about the varnish-commit
mailing list