Commit 9a93399c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Plug memory leaks related to starting/stopping child.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@675 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6f830d38
......@@ -125,6 +125,7 @@ start_child(void)
AZ(close(child_fds[1]));
child_fds[1] = -1;
assert(ev_listen == NULL);
e = ev_new();
assert(e != NULL);
e->fd = child_fds[0];
......@@ -134,6 +135,7 @@ start_child(void)
AZ(ev_add(mgt_evb, e));
ev_listen = e;
assert(ev_poker == NULL);
e = ev_new();
assert(e != NULL);
e->timeout = 3.0;
......@@ -167,8 +169,10 @@ stop_child(void)
child_state = CH_STOPPING;
if (ev_poker != NULL)
if (ev_poker != NULL) {
ev_del(mgt_evb, ev_poker);
free(ev_poker);
}
ev_poker = NULL;
printf("Clean child\n");
......@@ -194,8 +198,10 @@ mgt_sigchld(struct ev *e, int what)
(void)e;
(void)what;
if (ev_poker != NULL)
if (ev_poker != NULL) {
ev_del(mgt_evb, ev_poker);
free(ev_poker);
}
ev_poker = NULL;
r = wait4(-1, &status, WNOHANG, NULL);
......@@ -219,8 +225,10 @@ mgt_sigchld(struct ev *e, int what)
heritage.fds[3] = -1;
}
if (ev_listen != NULL)
if (ev_listen != NULL) {
ev_del(mgt_evb, ev_listen);
free(ev_listen);
}
ev_listen = NULL;
AZ(close(child_fds[0]));
......
......@@ -178,13 +178,17 @@ mgt_push_vcls_and_start(unsigned *status, char **p)
if (mgt_cli_askchild(status, p,
"config.load %s %s\n", vp->name, vp->fname))
return (1);
if (vp->active)
if (mgt_cli_askchild(status, p,
free(*p);
if (vp->active &&
mgt_cli_askchild(status, p,
"config.use %s\n", vp->name, vp->fname))
return (1);
free(*p);
}
if (mgt_cli_askchild(status, p, "start\n"))
return (1);
free(*p);
*p = NULL;
return (0);
}
......
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