[master] 4d27683 Alas poor struct proto, I hardly knew ye...

Poul-Henning Kamp phk at FreeBSD.org
Tue Feb 9 21:51:21 CET 2016


commit 4d27683332ec93b335bd5c41c904ecac3adac5ff
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 9 19:41:49 2016 +0000

    Alas poor struct proto, I hardly knew ye...

diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index fa9a5ff..6ba8e22 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -41,7 +41,7 @@
 #include <netinet/tcp.h>
 
 #include "cache.h"
-#include "cache_proto.h"
+#include "cache_transport.h"
 #include "cache_pool.h"
 #include "common/heritage.h"
 
@@ -330,7 +330,7 @@ vca_make_session(struct worker *wrk, void *arg)
 
 	sp->fd = wa->acceptsock;
 	wa->acceptsock = -1;
-	sp->sess_step = wa->acceptlsock->proto->first_step;
+	sp->sess_step = wa->acceptlsock->transport->first_step;
 
 	assert(wa->acceptaddrlen <= vsa_suckaddr_len);
 	SES_Reserve_remote_addr(sp, &sa);
@@ -349,7 +349,7 @@ vca_make_session(struct worker *wrk, void *arg)
 
 	VTCP_name(sa, laddr, sizeof laddr, lport, sizeof lport);
 
-	VSL(SLT_Begin, sp->vxid, "sess 0 %s", wa->acceptlsock->proto_name);
+	VSL(SLT_Begin, sp->vxid, "sess 0 %s", wa->acceptlsock->transport_name);
 	VSL(SLT_SessOpen, sp->vxid, "%s %s %s %s %s %.6f %d",
 	    raddr, rport, wa->acceptlsock->name, laddr, lport,
 	    sp->t_open, sp->fd);
@@ -495,7 +495,7 @@ vca_acct(void *arg)
 	(void)vca_tcp_opt_init();
 
 	VTAILQ_FOREACH(ls, &heritage.socks, list) {
-		CHECK_OBJ_NOTNULL(ls->proto, PROTO_MAGIC);
+		CHECK_OBJ_NOTNULL(ls->transport, TRANSPORT_MAGIC);
 		assert (ls->sock > 0);		// We know where stdin is
 		AZ(listen(ls->sock, cache_param->listen_depth));
 		vca_tcp_opt_set(ls->sock, 1);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 88ab55c..444bf1e 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -34,6 +34,7 @@
 #include <stdlib.h>
 
 #include "cache.h"
+#include "cache_transport.h"
 #include "cache_filter.h"
 
 #include "vtim.h"
diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h
index 181f739..d5b4d10 100644
--- a/bin/varnishd/cache/cache_priv.h
+++ b/bin/varnishd/cache/cache_priv.h
@@ -29,21 +29,6 @@
  * Stuff that should *never* be exposed to a VMOD
  */
 
-/*--------------------------------------------------------------------
- * A transport is how we talk HTTP for a given request.
- * This is different from a protocol because ESI child requests have
- * their own "protocol" to talk to the parent ESI request, which may
- * or may not, be talking a "real" HTTP protocol itself.
- */
-
-typedef void vtr_deliver_f (struct req *, struct boc *, int sendbody);
-
-struct transport {
-	unsigned		magic;
-#define TRANSPORT_MAGIC		0xf157f32f
-	vtr_deliver_f		*deliver;
-};
-
 /* Prototypes etc ----------------------------------------------------*/
 
 /* cache_acceptor.c */
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 04c4e7f..2d65fbd 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -41,6 +41,7 @@
 #include "cache.h"
 #include "cache_director.h"
 #include "cache_filter.h"
+#include "cache_transport.h"
 
 #include "hash/hash_slinger.h"
 #include "vcl.h"
diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h
index c432192..888bd3a 100644
--- a/bin/varnishd/cache/cache_transport.h
+++ b/bin/varnishd/cache/cache_transport.h
@@ -25,10 +25,19 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
+ * A transport is how we talk HTTP for a given request.
+ *
+ * This is different from a protocol because ESI child requests have
+ * their own "protocol" to talk to the parent ESI request, which may
+ * or may not, be talking a "real" HTTP protocol itself.
+ *
  */
 
-struct proto {
+typedef void vtr_deliver_f (struct req *, struct boc *, int sendbody);
+
+struct transport {
 	unsigned		magic;
-#define PROTO_MAGIC		0x711e77c1
+#define TRANSPORT_MAGIC		0xf157f32f
+	vtr_deliver_f		*deliver;
 	enum sess_step		first_step;
 };
diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h
index cbb8f9c..192d899 100644
--- a/bin/varnishd/common/heritage.h
+++ b/bin/varnishd/common/heritage.h
@@ -31,7 +31,6 @@
 
 struct vsm_sc;
 struct suckaddr;
-struct proto;
 
 struct listen_sock {
 	unsigned			magic;
@@ -40,12 +39,12 @@ struct listen_sock {
 	int				sock;
 	char				*name;
 	struct suckaddr			*addr;
-	const struct proto		*proto;
-	const char			*proto_name;
+	const struct transport		*transport;
+	const char			*transport_name;
 };
 
-extern const struct proto VPX_proto;
-extern const struct proto HTTP1_proto;
+extern const struct transport PROXY_transport;
+extern const struct transport HTTP1_transport;
 
 VTAILQ_HEAD(listen_sock_head, listen_sock);
 
diff --git a/bin/varnishd/http1/cache_http1.h b/bin/varnishd/http1/cache_http1.h
index f717b78..597b432 100644
--- a/bin/varnishd/http1/cache_http1.h
+++ b/bin/varnishd/http1/cache_http1.h
@@ -39,7 +39,7 @@ extern const int HTTP1_Req[3];
 extern const int HTTP1_Resp[3];
 
 /* cache_http1_deliver.c */
-vtr_deliver_f V1D_Deliver;
+void V1D_Deliver(struct req *, struct boc *, int sendbody);
 
 /* cache_http1_pipe.c */
 struct v1p_acct {
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index d86ba28..513875d 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -38,15 +38,16 @@
 #include <stdlib.h>
 
 #include "cache/cache.h"
-#include "cache/cache_proto.h"
+#include "cache/cache_transport.h"
 #include "cache_http1.h"
 #include "hash/hash_slinger.h"
 
 #include "vtcp.h"
 
-static const struct transport http1_transport = {
-	.magic = TRANSPORT_MAGIC,
-	.deliver = V1D_Deliver,
+const struct transport HTTP1_transport = {
+	.magic =		TRANSPORT_MAGIC,
+	.deliver =		V1D_Deliver,
+	.first_step =		S_STP_H1NEWSESS,
 };
 
 /*----------------------------------------------------------------------
@@ -264,7 +265,7 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 			sp->sess_step = S_STP_H1PROC;
 			break;
 		case S_STP_H1PROC:
-			req->transport = &http1_transport;
+			req->transport = &HTTP1_transport;
 			if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK) {
 				sp->sess_step = S_STP_H1BUSY;
 				return;
@@ -286,8 +287,3 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 
 	}
 }
-
-const struct proto HTTP1_proto = {
-	.magic =		PROTO_MAGIC,
-	.first_step =		S_STP_H1NEWSESS,
-};
diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index 63adbac..bda2063 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -116,8 +116,8 @@ struct mac_help {
 #define MAC_HELP_MAGIC		0x1e00a9d9
 	int			good;
 	const char		*name;
-	const char		*proto_name;
-	const struct proto	*proto;
+	const char		*transport_name;
+	const struct transport	*transport;
 };
 
 static int __match_proto__(vss_resolved_f)
@@ -140,8 +140,8 @@ mac_callback(void *priv, const struct suckaddr *sa)
 	AN(ls->addr);
 	ls->name = strdup(mh->name);
 	AN(ls->name);
-	ls->proto_name = mh->proto_name;
-	ls->proto = mh->proto;
+	ls->transport_name = mh->transport_name;
+	ls->transport = mh->transport;
 	VTAILQ_INSERT_TAIL(&heritage.socks, ls, list);
 	mh->good++;
 	return (0);
@@ -197,13 +197,13 @@ MAC_Arg(const char *arg)
 	mh->name = av[1];
 
 	if (av[2] == NULL || !strcmp(av[2], "HTTP/1")) {
-		mh->proto = &HTTP1_proto;
-		mh->proto_name = "HTTP/1";
+		mh->transport = &HTTP1_transport;
+		mh->transport_name = "HTTP/1";
 		if (av[2] != NULL && av[3] != NULL)
 			ARGV_ERR("Too many sub-arguments to -a(HTTP/1)\n");
 	} else if (!strcmp(av[2], "PROXY")) {
-		mh->proto = &VPX_proto;
-		mh->proto_name = "PROXY";
+		mh->transport = &PROXY_transport;
+		mh->transport_name = "PROXY";
 		if (av[3] != NULL)
 			ARGV_ERR("Too many sub-arguments to -a(PROXY)\n");
 	} else {
diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c
index a73f21a..8df3d84 100644
--- a/bin/varnishd/proxy/cache_proxy_proto.c
+++ b/bin/varnishd/proxy/cache_proxy_proto.c
@@ -39,7 +39,7 @@
 #include <string.h>
 
 #include "../cache/cache.h"
-#include "../cache/cache_proto.h"
+#include "../cache/cache_transport.h"
 
 #include "vend.h"
 #include "vsa.h"
@@ -381,7 +381,7 @@ VPX_Proto_Sess(struct worker *wrk, void *priv)
 	wrk->task.priv = req;
 }
 
-const struct proto VPX_proto = {
-	.magic =		PROTO_MAGIC,
+const struct transport PROXY_transport = {
+	.magic =		TRANSPORT_MAGIC,
 	.first_step =		S_STP_PROXYNEWSESS,
 };



More information about the varnish-commit mailing list