Commit 82411494 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Draw the line between the managers and the childs copy of the struct

params much clearer.  Manager should never read the childs copy.
parent a2dbc597
......@@ -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.
......
......@@ -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);
......
......@@ -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;
......
......@@ -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));
......
This diff is collapsed.
......@@ -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. "
......
......@@ -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");
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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[];
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