[master] fde2d23 Make it a failure to not get all acceptor sockets on child start.

Poul-Henning Kamp phk at FreeBSD.org
Mon Mar 16 11:15:35 CET 2015


commit fde2d23125673f7ead9d74abc436b8ee9c907ed9
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 16 10:15:05 2015 +0000

    Make it a failure to not get all acceptor sockets on child start.

diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index ac1000d..a49ec16 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -33,7 +33,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <fcntl.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -58,26 +58,23 @@ int
 MAC_open_sockets(void)
 {
 	struct listen_sock *ls;
-	int good = 0;
+	int fail;
 
 	VJ_master(JAIL_MASTER_PRIVPORT);
 	VTAILQ_FOREACH(ls, &heritage.socks, list) {
-		if (ls->sock >= 0) {
-			good++;
-			continue;
-		}
+		assert(ls->sock < 0);
 		ls->sock = VTCP_bind(ls->addr, NULL);
 		if (ls->sock < 0)
-			continue;
-
+			break;
 		mgt_child_inherit(ls->sock, "sock");
-
-		good++;
 	}
+	fail = errno;
 	VJ_master(JAIL_MASTER_LOW);
-	if (!good)
-		return (1);
-	return (0);
+	if (ls == NULL)
+		return (0);
+	MAC_close_sockets();
+	errno = fail;
+	return (-1);
 }
 
 /*--------------------------------------------------------------------*/
@@ -158,7 +155,7 @@ MAC_Arg(const char *arg)
 	mh->err = &err;
 	error = VSS_resolver(av[1], "80", mac_callback, mh, &err);
 	if (mh->good == 0 || err != NULL)
-		ARGV_ERR("Could not open %s: %s\n", av[1], err);
+		ARGV_ERR("Could not bind to address %s: %s\n", av[1], err);
 	AZ(error);
 	FREE_OBJ(mh);
 }
diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc
index 8f31bb6..d4ce742 100644
--- a/bin/varnishtest/tests/c00003.vtc
+++ b/bin/varnishtest/tests/c00003.vtc
@@ -4,7 +4,7 @@ varnishtest "Check that we fail to start if any listen address does not work"
 # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0.
 
 # All bad listen addresses
-err_shell "Could not open 192.0.2.255:0" {${varnishd} -F -a "${bad_ip}:0" -b /// -n ${tmpdir} 2>&1 }
+err_shell "Could not bind to address 192.0.2.255:0" {${varnishd} -F -a "${bad_ip}:0" -b /// -n ${tmpdir} 2>&1 }
 
 # Just one bad listen addresses
 err_shell "Error: XXX: not yet" {${varnishd} -F -a "127.0.0.1:0,${bad_ip}:0" -b /// -n ${tmpdir} 2>&1 }



More information about the varnish-commit mailing list