[4.1] dee325d Add some error checking to child_poker

PÃ¥l Hermunn Johansen hermunn at varnish-software.com
Wed Jul 27 17:17:08 CEST 2016


commit dee325d3063b4779ed41df534349f7f6a7d5101f
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 e602607..3ac39a0 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -252,6 +252,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;
@@ -259,9 +261,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