[master] 255b99a Add a new Req State to handle Expect & Connection, use it for H2.

Poul-Henning Kamp phk at FreeBSD.org
Sun Mar 12 20:36:05 CET 2017


commit 255b99a90f82c5a3c41c9cd8b02524adf3d995a6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Mar 12 19:34:46 2017 +0000

    Add a new Req State to handle Expect & Connection, use it for H2.

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index b8c4d20..733e45b 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -94,6 +94,17 @@ CNT_GotReq(struct worker *wrk, struct req *req)
 	return (0);
 }
 
+static enum req_fsm_nxt
+cnt_transport(struct worker *wrk, struct req *req)
+{
+
+	if (CNT_GotReq(wrk, req))
+		return (REQ_FSM_DONE);
+
+	req->req_step = R_STP_RECV;
+	return (REQ_FSM_MORE);
+}
+
 /*--------------------------------------------------------------------
  * Deliver an object to client
  */
@@ -961,6 +972,7 @@ CNT_Request(struct worker *wrk, struct req *req)
 	 */
 	assert(
 	    req->req_step == R_STP_LOOKUP ||
+	    req->req_step == R_STP_TRANSPORT ||
 	    req->req_step == R_STP_RECV);
 
 	AN(req->vsl->wid & VSL_CLIENTMARKER);
diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h
index 5599172..a3862e5 100644
--- a/bin/varnishd/http2/cache_http2.h
+++ b/bin/varnishd/http2/cache_http2.h
@@ -220,3 +220,4 @@ void h2_del_req(struct worker *, struct h2_req *);
 int h2_rxframe(struct worker *, struct h2_sess *);
 h2_error h2_set_setting(struct h2_sess *, const uint8_t *);
 void h2_req_body(struct req*);
+task_func_t h2_do_req;
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index f4e7fc9..f6287b8 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -427,7 +427,7 @@ h2_rx_settings(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
  * Incoming HEADERS, this is where the partys at...
  */
 
-static void __match_proto__(task_func_t)
+void __match_proto__(task_func_t)
 h2_do_req(struct worker *wrk, void *priv)
 {
 	struct req *req;
@@ -436,8 +436,8 @@ h2_do_req(struct worker *wrk, void *priv)
 	CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC);
 	CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC);
 	THR_SetRequest(req);
-	if (!CNT_GotReq(wrk, req))
-		assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK);
+	req->req_step = R_STP_TRANSPORT;
+	assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK);
 	THR_SetRequest(NULL);
 	VSL(SLT_Debug, 0, "H2REQ CNT done");
 	/* XXX clean up req */
@@ -491,7 +491,6 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
 
 	h2->new_req = req;
 	req->sp = h2->sess;
-	req->req_step = R_STP_RECV;
 	req->transport = &H2_transport;
 
 	req->t_first = VTIM_real();
diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index 073d04f..6836f52 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -115,28 +115,6 @@ h2_new_sess(const struct worker *wrk, struct sess *sp, struct req *srq)
 	return (h2);
 }
 
-/**********************************************************************
- * Incoming HEADERS, this is where the partys at...
- */
-
-static void __match_proto__(task_func_t)
-h2_do_req(struct worker *wrk, void *priv)
-{
-	struct req *req;
-	struct h2_req *r2;
-
-	CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC);
-	CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC);
-	THR_SetRequest(req);
-	if (!CNT_GotReq(wrk, req))
-		assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK);
-	THR_SetRequest(NULL);
-	VSL(SLT_Debug, 0, "H2REQ CNT done");
-	/* XXX clean up req */
-	r2->state = H2_S_CLOSED;
-	h2_del_req(wrk, r2);
-}
-
 /**********************************************************************/
 
 enum htc_status_e __match_proto__(htc_complete_f)
diff --git a/include/tbl/steps.h b/include/tbl/steps.h
index ab8d742..12deb9c 100644
--- a/include/tbl/steps.h
+++ b/include/tbl/steps.h
@@ -31,6 +31,7 @@
 /*lint -save -e525 -e539 */
 
 #ifdef REQ_STEP
+  REQ_STEP(transport,		TRANSPORT,	(wrk, req))
   REQ_STEP(restart,		RESTART,	(wrk, req))
   REQ_STEP(recv,		RECV,		(wrk, req))
   REQ_STEP(pipe,		PIPE,		(wrk, req))



More information about the varnish-commit mailing list