[master] 275cf84 Split sending bereq into its own function, so the VBC/waiter dance does not pollute the http1 code.

Poul-Henning Kamp phk at FreeBSD.org
Wed Jun 24 22:45:12 CEST 2015


commit 275cf8408db23dadcaef8c97d0be920529353921
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jun 24 18:48:29 2015 +0000

    Split sending bereq into its own function, so the VBC/waiter dance
    does not pollute the http1 code.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 46fe79c..effe64a 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -215,7 +215,16 @@ vbe_dir_gethdrs(const struct director *d, struct worker *wrk,
 		if (bo->htc->vbc->state != VBC_STATE_STOLEN)
 			extrachance = 0;
 
-		i = V1F_fetch_hdr(wrk, bo, bp->hosthdr);
+		i = V1F_SendReq(wrk, bo, bp->hosthdr);
+
+		if (bo->htc->vbc->state != VBC_STATE_USED)
+			VBT_Wait(wrk, bo->htc->vbc);
+
+		assert(bo->htc->vbc->state == VBC_STATE_USED);
+
+		if (!i)
+			i = V1F_FetchRespHdr(bo);
+
 		/*
 		 * If we recycled a backend connection, there is a finite chance
 		 * that the backend closed it before we got the bereq to it.
diff --git a/bin/varnishd/http1/cache_http1.h b/bin/varnishd/http1/cache_http1.h
index dcd4cb0..8a80605 100644
--- a/bin/varnishd/http1/cache_http1.h
+++ b/bin/varnishd/http1/cache_http1.h
@@ -28,7 +28,8 @@
  */
 
 /* cache_http1_fetch.c [V1F] */
-int V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host);
+int V1F_SendReq(struct worker *, struct busyobj *, const char *def_host);
+int V1F_FetchRespHdr(struct busyobj *);
 void V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc);
 
 /* cache_http1_fsm.c [HTTP1] */
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 6223b15..15d4168 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -67,21 +67,18 @@ vbf_iter_req_body(struct req *req, void *priv, void *ptr, size_t l)
 }
 
 /*--------------------------------------------------------------------
- * Send request, and receive the HTTP protocol response, but not the
- * response body.
+ * Send request to backend, including any req.body
  *
  * Return value:
- *	-1 failure, not retryable
  *	 0 success
- *	 1 failure which can be retried.
+ *	 1 failure
  */
 
 int
-V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host)
+V1F_SendReq(struct worker *wrk, struct busyobj *bo, const char *def_host)
 {
 	struct http *hp;
-	enum htc_status_e hs;
-	int j, first;
+	int j;
 	ssize_t i;
 	struct http_conn *htc;
 	int do_chunked = 0;
@@ -140,15 +137,27 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, const char *def_host)
 		return (1);
 	}
 	VSLb_ts_busyobj(bo, "Bereq", W_TIM_real(wrk));
+	return (0);
+}
 
-	VSC_C_main->backend_req++;
+int
+V1F_FetchRespHdr(struct busyobj *bo)
+{
 
-	/* Receive response */
+	struct http *hp;
+	enum htc_status_e hs;
+	int first;
+	struct http_conn *htc;
 
-	if (htc->vbc->state != VBC_STATE_USED)
-		VBT_Wait(wrk, htc->vbc);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
+	CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC);
 
-	assert(htc->vbc->state == VBC_STATE_USED);
+	htc = bo->htc;
+
+	VSC_C_main->backend_req++;
+
+	/* Receive response */
 
 	SES_RxInit(htc, bo->ws, cache_param->http_resp_size,
 	    cache_param->http_resp_hdr_len);



More information about the varnish-commit mailing list