[master] 9d51cf7 Make H2 handle the waiting list.

Poul-Henning Kamp phk at FreeBSD.org
Sun Mar 12 21:52:06 CET 2017


commit 9d51cf7e382cbbdf007a3d54ff506de145d6963d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun Mar 12 20:51:02 2017 +0000

    Make H2 handle the waiting list.

diff --git a/bin/varnishd/http1/cache_http1.h b/bin/varnishd/http1/cache_http1.h
index bd74ed4..f3591127 100644
--- a/bin/varnishd/http1/cache_http1.h
+++ b/bin/varnishd/http1/cache_http1.h
@@ -34,7 +34,6 @@ int V1F_FetchRespHdr(struct busyobj *);
 int V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc);
 
 /* cache_http1_fsm.c [HTTP1] */
-void HTTP1_Session(struct worker *, struct req *);
 extern const int HTTP1_Req[3];
 extern const int HTTP1_Resp[3];
 
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index 4b238c3..7ebee6b 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -51,6 +51,8 @@ static const char H1PROC[] = "HTTP1::Proc";
 static const char H1BUSY[] = "HTTP1::Busy";
 static const char H1CLEANUP[] = "HTTP1::Cleanup";
 
+static void HTTP1_Session(struct worker *, struct req *);
+
 static void
 http1_setstate(const struct sess *sp, const char *s)
 {
@@ -325,7 +327,7 @@ http1_dissect(struct worker *wrk, struct req *req)
 /*----------------------------------------------------------------------
  */
 
-void
+static void
 HTTP1_Session(struct worker *wrk, struct req *req)
 {
 	enum htc_status_e hs;
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index f6287b8..0add0f9 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -436,13 +436,12 @@ 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);
-	req->req_step = R_STP_TRANSPORT;
-	assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK);
+	if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) {
+		VSL(SLT_Debug, 0, "H2REQ CNT done");
+		r2->state = H2_S_CLOSED;
+		h2_del_req(wrk, r2);
+	}
 	THR_SetRequest(NULL);
-	VSL(SLT_Debug, 0, "H2REQ CNT done");
-	/* XXX clean up req */
-	r2->state = H2_S_CLOSED;
-	h2_del_req(wrk, r2);
 }
 
 static h2_error
@@ -464,6 +463,7 @@ h2_end_headers(const struct worker *wrk, const struct h2_sess *h2,
 	else
 		req->req_body_status = REQ_BODY_WITHOUT_LEN;
 
+	req->req_step = R_STP_TRANSPORT;
 	req->task.func = h2_do_req;
 	req->task.priv = req;
 	XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ));
diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index 6836f52..6922166 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -223,6 +223,7 @@ h2_ou_session(const struct worker *wrk, struct h2_sess *h2,
 	(void)h2_new_req(wrk, h2, 1, req);
 	req->req_step = R_STP_RECV;
 	req->transport = &H2_transport;
+	req->req_step = R_STP_TRANSPORT;
 	req->task.func = h2_do_req;
 	req->task.priv = req;
 	req->err_code = 0;
@@ -336,6 +337,30 @@ h2_new_session(struct worker *wrk, void *arg)
 	h2_del_req(wrk, h2->req0);
 }
 
+static void __match_proto__(vtr_reembark_f)
+h2_reembark(struct worker *wrk, struct req *req)
+{
+	struct sess *sp;
+
+	sp = req->sp;
+	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+	assert(req->transport == &H2_transport);
+
+	if (!SES_Reschedule_Req(req))
+		return;
+
+	/* Couldn't schedule, ditch */
+	wrk->stats->busy_wakeup--;
+	wrk->stats->busy_killed++;
+	AN (req->vcl);
+	VCL_Rel(&req->vcl);
+	CNT_AcctLogCharge(wrk->stats, req);
+	Req_Release(req);
+	DSL(DBG_WAITINGLIST, req->vsl->wid, "kill from waiting list");
+	usleep(10000);
+}
+
+
 struct transport H2_transport = {
 	.name =			"H2",
 	.magic =		TRANSPORT_MAGIC,
@@ -344,4 +369,5 @@ struct transport H2_transport = {
 	.deliver =		h2_deliver,
 	.req_body =		h2_req_body,
 	.minimal_response =	h2_minimal_response,
+	.reembark =		h2_reembark,
 };
diff --git a/bin/varnishtest/tests/t02009.vtc b/bin/varnishtest/tests/t02009.vtc
new file mode 100644
index 0000000..2dc1cde
--- /dev/null
+++ b/bin/varnishtest/tests/t02009.vtc
@@ -0,0 +1,31 @@
+varnishtest "H2 on waiting list"
+
+barrier b1 cond 2
+
+server s1 {
+	rxreq
+	barrier b1 sync
+	delay 1
+	txresp -hdr "Content-Type: text/plain" -body response
+} -start
+
+varnish v1 -vcl+backend {} -start
+varnish v1 -cliok {param.set feature +http2}
+varnish v1 -cliok "param.set debug +syncvsl"
+
+client c1 {
+	stream 1 {
+		txreq 
+		rxresp
+		expect resp.http.content-Type == "text/plain"
+		expect resp.body == response
+	} -start
+	stream 5 {
+		barrier b1 sync
+		txreq 
+		rxresp
+		expect resp.http.content-Type == "text/plain"
+		expect resp.body == response
+	} -run
+	stream 1 -wait
+} -run



More information about the varnish-commit mailing list