Skip to content

Commit

Permalink
Add some error checking to child_poker
Browse files Browse the repository at this point in the history
The child_poker lives in the manager process, and sends pings to the
child. With this patch we check that we actually get a PONG back, and
not some random data. If problems are detected, we kill the child.

Related to: varnishcache#2010
  • Loading branch information
hermunn committed Jul 14, 2016
1 parent d1fd1ac commit 11ff169
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions bin/varnishd/mgt/mgt_child.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,16 +248,30 @@ child_listener(const struct vev *e, int what)
static int __match_proto__(vev_cb_f)
child_poker(const struct vev *e, int what)
{
char * r = NULL;
unsigned status;

(void)e;
(void)what;
if (child_state != CH_RUNNING)
return (1);
if (child_pid < 0)
return (0);
if (!mgt_cli_askchild(NULL, NULL, "ping\n"))
return (0);
return (0);
if (!mgt_cli_askchild(&status, &r, "ping\n")) {
if (strncmp("PONG ", r, 5)) {
MGT_complain(C_ERR,
"Unexpected reply from ping: %u %s",
status, r);
MGT_Child_Cli_Fail();
}
}
else {
MGT_complain(C_ERR, "Did not get a 200 from ping: %u %s",
status, r);
MGT_Child_Cli_Fail();
}
free(r);
return 0;
}

/*=====================================================================
Expand Down

0 comments on commit 11ff169

Please sign in to comment.