[master] 8322836 Add some error checking to child_poker
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Wed Jul 27 17:13:09 CEST 2016
commit 8322836984bd0b234cf791b804b08232bd85c981
Author: Pål Hermunn Johansen <hermunn at varnish-software.com>
Date: Thu Jul 14 16:20:21 2016 +0200
Add some error checking to child_poker
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: #2010
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index 836a049..4508117 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -248,6 +248,8 @@ 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;
@@ -255,9 +257,14 @@ child_poker(const struct vev *e, int what)
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") || strncmp("PONG ", r, 5)) {
+ MGT_complain(C_ERR, "Unexpected reply from ping: %u %s",
+ status, r);
+ if (status != CLIS_COMMS)
+ MGT_Child_Cli_Fail();
+ }
+ free(r);
+ return 0;
}
/*=====================================================================
More information about the varnish-commit
mailing list