[master] b5593e2 Fix #2389

Poul-Henning Kamp phk at FreeBSD.org
Tue Sep 19 07:29:07 UTC 2017


commit b5593e22805351a0121924626624eb33641847f6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Sep 19 07:26:19 2017 +0000

    Fix #2389
    
    Make the subargument to -a select the overall protocol (PROXY/HTTP)
    but, at least for now, not distinguish versions of these protocols.

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index 79d5e41..a5131a0 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -674,7 +674,8 @@ XPORT_Find(const char *name)
 	ASSERT_MGT();
 
 	VTAILQ_FOREACH(xp, &transports, list)
-		if (!strcasecmp(xp->name, name))
+		if (xp->proto_ident != NULL &&
+		    !strcasecmp(xp->proto_ident, name))
 			return (xp);
 	return (NULL);
 }
diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h
index 3433959..5de0920 100644
--- a/bin/varnishd/cache/cache_transport.h
+++ b/bin/varnishd/cache/cache_transport.h
@@ -50,6 +50,7 @@ struct transport {
 
 	uint16_t			number;
 
+	const char			*proto_ident;	// for -a args
 	const char			*name;
 
 	task_func_t			*new_session;
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index ceaf4c8..5657e6f 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -240,6 +240,7 @@ http1_minimal_response(struct req *req, uint16_t status)
 
 struct transport HTTP1_transport = {
 	.name =			"HTTP/1",
+	.proto_ident =		"HTTP",
 	.magic =		TRANSPORT_MAGIC,
 	.deliver =		V1D_Deliver,
 	.minimal_response =	http1_minimal_response,
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index f5ba1e3..b5b46a4 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -54,7 +54,7 @@ extern const char * const builtin_vcl;
 /* mgt_acceptor.c */
 
 void MAC_Arg(const char *);
-void MAC_reopen_sockets(struct cli *);
+void MAC_reopen_sockets(void);
 
 /* mgt_child.c */
 void MCH_Init(void);
diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index fa40577..695e882 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -76,7 +76,7 @@ mac_opensocket(struct listen_sock *ls)
  */
 
 void
-MAC_reopen_sockets(struct cli *cli)
+MAC_reopen_sockets(void)
 {
 	struct listen_sock *ls;
 	int fail;
@@ -87,14 +87,9 @@ MAC_reopen_sockets(struct cli *cli)
 		VJ_master(JAIL_MASTER_LOW);
 		if (fail == 0)
 			continue;
-		if (cli == NULL)
-			MGT_Complain(C_ERR,
-			    "Could not reopen listen socket %s: %s",
-			    ls->endpoint, strerror(fail));
-		else
-			VCLI_Out(cli,
-			    "Could not reopen listen socket %s: %s\n",
-			    ls->endpoint, strerror(fail));
+		MGT_Complain(C_ERR,
+		    "Could not reopen listen socket %s: %s",
+		    ls->endpoint, strerror(fail));
 	}
 }
 
@@ -184,7 +179,7 @@ MAC_Arg(const char *spec)
 	la->name = name;
 
 	if (av[2] == NULL) {
-		xp = XPORT_Find("http/1");
+		xp = XPORT_Find("http");
 	} else {
 		xp = XPORT_Find(av[2]);
 		if (xp == NULL)
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index b3b8856..38d0674 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -525,7 +525,7 @@ mgt_reap_child(void)
 		fprintf(stderr, "WAIT 0x%jx\n", (uintmax_t)r);
 	assert(r == child_pid);
 
-	MAC_reopen_sockets(NULL);
+	MAC_reopen_sockets();
 
 	VSB_printf(vsb, "Child (%jd) %s", (intmax_t)r,
 	    status ? "died" : "ended");
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 6da09e5..d4eec41 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -91,7 +91,8 @@ usage(void)
 	printf(FMT, "-a address[:port][,proto]",
 	    "HTTP listen address and port");
 	printf(FMT, "", "Can be specified multiple times.");
-	printf(FMT, "", "  default: \":80,HTTP/1\"");
+	printf(FMT, "", "  default: \":80,HTTP\"");
+	printf(FMT, "", "Proto can be \"PROXY\" or \"HTTP\" (default)");
 	printf(FMT, "-b address[:port]", "Backend address and port");
 	printf(FMT, "", "  default: \":80\"");
 	printf(FMT, "-f vclfile", "VCL program");
diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index b9f1626..8444f39 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -379,6 +379,7 @@ vpx_new_session(struct worker *wrk, void *arg)
 
 struct transport PROXY_transport = {
 	.name =			"PROXY",
+	.proto_ident =		"PROXY",
 	.magic =		TRANSPORT_MAGIC,
 	.new_session =		vpx_new_session,
 };
diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc
index 01adffd..d8d74b1 100644
--- a/bin/varnishtest/tests/c00003.vtc
+++ b/bin/varnishtest/tests/c00003.vtc
@@ -11,7 +11,10 @@ shell -err -expect "Too many sub-arguments" {
 	varnishd -a 127.0.0.1:80000,PROXY,FOO -d
 }
 shell -err -expect "Too many sub-arguments" {
-	varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d
+	varnishd -a 127.0.0.1:80000,HTTP,FOO -d
+}
+shell -err -expect "Got no socket" {
+	varnishd -a 239.255.255.255:0,HTTP -d
 }
 
 # This requires non-local binds to be disabled.  If you see this fail


More information about the varnish-commit mailing list