[master] 3cc846e Introduce "transports" which is how responses to requests gets delivered.

Poul-Henning Kamp phk at FreeBSD.org
Thu May 14 18:12:23 CEST 2015


commit 3cc846eea3c42c11f73bd4890b47723241a1b443
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu May 14 16:09:50 2015 +0000

    Introduce "transports" which is how responses to requests gets
    delivered.
    
    Transports are a superset of protocols because internal requests,
    notably ESI:includes, doesn't use a HTTP protocol to deliver their
    response, but have have ødipal ways of doing things.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7986cb3..2f0d228 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -111,6 +111,7 @@ struct object;
 struct objhead;
 struct pool;
 struct poolparam;
+struct transport;
 struct req;
 struct sess;
 struct suckaddr;
@@ -541,6 +542,10 @@ struct req {
 	struct sess		*sp;
 	struct worker		*wrk;
 	struct pool_task	task;
+
+	const struct transport	*transport;
+	void			*transport_priv;
+
 	enum req_step		req_step;
 	VTAILQ_ENTRY(req)	w_list;
 
@@ -672,6 +677,21 @@ struct sess {
 
 };
 
+/*--------------------------------------------------------------------
+ * 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 transport {
+	unsigned		magic;
+#define TRANSPORT_MAGIC		0xf157f32f
+	vtr_deliver_f		*deliver;
+};
+
 /* Prototypes etc ----------------------------------------------------*/
 
 /* Cross file typedefs */
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index c4594a7..8f0f1a4 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -80,7 +80,8 @@ cnt_vdp(struct req *req, struct busyobj *bo)
 			VRG_dorange(req, r);
 	}
 
-	V1D_Deliver(req);
+	CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC);
+	req->transport->deliver(req);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 984a3f1..221173d 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -60,7 +60,7 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv,
 /*--------------------------------------------------------------------
  */
 
-void
+void __match_proto__(vtr_deliver_f)
 V1D_Deliver(struct req *req)
 {
 	enum objiter_status ois;
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index 9d08d29..8954061 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -42,6 +42,11 @@
 
 #include "vtcp.h"
 
+static const struct transport http1_transport = {
+	.magic = TRANSPORT_MAGIC,
+	.deliver = V1D_Deliver,
+};
+
 /*----------------------------------------------------------------------
  */
 
@@ -255,10 +260,12 @@ HTTP1_Session(struct worker *wrk, struct req *req)
 			sp->sess_step = S_STP_H1PROC;
 			break;
 		case S_STP_H1PROC:
+			req->transport = &http1_transport;
 			if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK) {
 				sp->sess_step = S_STP_H1BUSY;
 				return;
 			}
+			req->transport = NULL;
 			sp->sess_step = S_STP_H1CLEANUP;
 			break;
 		case S_STP_H1CLEANUP:



More information about the varnish-commit mailing list