[master] 4efd5c9 Finally pull the remains of cnt_fetch() entirely into VBF_Fetch()

Poul-Henning Kamp phk at varnish-cache.org
Fri May 24 13:56:23 CEST 2013


commit 4efd5c96934f20bd8563b1db2af3d1d86c2f41bf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri May 24 11:55:52 2013 +0000

    Finally pull the remains of cnt_fetch() entirely into VBF_Fetch()

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index f48fb20..5e07962 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -772,65 +772,6 @@ vbf_proc_resp(struct worker *wrk, struct busyobj *bo)
 
 }
 
-/*--------------------------------------------------------------------
- */
-
-static int
-cnt_fetch(struct worker *wrk, struct req *req, struct busyobj *bo)
-{
-	int i;
-
-	HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp);
-
-	i = FetchHdr(wrk, bo, req);
-	/*
-	 * If we recycle a backend connection, there is a finite chance
-	 * that the backend closed it before we get a request to it.
-	 * Do a single retry in that case.
-	 */
-	if (i == 1) {
-		VSC_C_main->backend_retry++;
-		i = FetchHdr(wrk, bo, req);
-	}
-
-	if (!i) {
-		vbf_proc_resp(wrk, bo);
-
-		if (wrk->handling == VCL_RET_DELIVER)
-			return (0);
-
-		/* We are not going to fetch the body, Close the connection */
-		VDI_CloseFd(&bo->vbc);
-	} else {
-		wrk->handling = VCL_RET_ERROR;
-		bo->err_code = 503;
-	}
-
-	/* Clean up partial fetch */
-	AZ(bo->vbc);
-
-	if (bo->fetch_objcore->objhead != NULL ||
-	    wrk->handling == VCL_RET_RESTART ||
-	    wrk->handling == VCL_RET_ERROR) {
-		CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
-		AZ(HSH_Deref(&wrk->stats, bo->fetch_objcore, NULL));
-		bo->fetch_objcore = NULL;
-	}
-	assert(bo->refcount == 2);
-	bo->storage_hint = NULL;
-	bo->director = NULL;
-	VBO_DerefBusyObj(wrk, &bo);
-
-	switch (wrk->handling) {
-	case VCL_RET_ERROR:
-		return (-1);
-	case VCL_RET_RESTART:
-		INCOMPL();
-	default:
-		WRONG("Illegal action in vcl_fetch{}");
-	}
-}
-
 int
 VBF_Fetch(struct worker *wrk, struct req *req)
 {
@@ -859,12 +800,58 @@ VBF_Fetch(struct worker *wrk, struct req *req)
 	vbf_make_bereq(wrk, req, bo);
 	xxxassert (wrk->handling == VCL_RET_FETCH);
 
-	i = cnt_fetch(wrk, bo->do_pass ? req : NULL, bo);
+	HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp);
+
+	if (!bo->do_pass)
+		req = NULL;
+
+	i = FetchHdr(wrk, bo, req);
+	/*
+	 * If we recycle a backend connection, there is a finite chance
+	 * that the backend closed it before we get a request to it.
+	 * Do a single retry in that case.
+	 */
+	if (i == 1) {
+		VSC_C_main->backend_retry++;
+		i = FetchHdr(wrk, bo, req);
+	}
+
+	if (i) {
+		wrk->handling = VCL_RET_ERROR;
+		bo->err_code = 503;
+	} else {
+		vbf_proc_resp(wrk, bo);
+		if (wrk->handling != VCL_RET_DELIVER)
+			VDI_CloseFd(&bo->vbc);
+	}
+
+	if (wrk->handling != VCL_RET_DELIVER) {
+		/* Clean up partial fetch */
+		AZ(bo->vbc);
 
-	if (i)
-		return (i);
+		if (bo->fetch_objcore->objhead != NULL ||
+		    wrk->handling == VCL_RET_RESTART ||
+		    wrk->handling == VCL_RET_ERROR) {
+			CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC);
+			AZ(HSH_Deref(&wrk->stats, bo->fetch_objcore, NULL));
+			bo->fetch_objcore = NULL;
+		}
+		assert(bo->refcount == 2);
+		bo->storage_hint = NULL;
+		bo->director = NULL;
+		VBO_DerefBusyObj(wrk, &bo);
 
-	if (bo->fetch_objcore->objhead == NULL) 
+		switch (wrk->handling) {
+		case VCL_RET_ERROR:
+			return (-1);
+		case VCL_RET_RESTART:
+			INCOMPL();
+		default:
+			WRONG("Illegal action in vcl_fetch{}");
+		}
+	}
+
+	if (bo->fetch_objcore->objhead == NULL)
 		AN(bo->do_pass);
 
 	/* No reason to try streaming a non-existing body */
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 6c7f015..36c20ab 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -506,7 +506,7 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size,
  */
 
 static struct object *
-smp_allocobj(struct stevedore *stv, struct busyobj *bo, 
+smp_allocobj(struct stevedore *stv, struct busyobj *bo,
     unsigned ltot, const struct stv_objsecrets *soc)
 {
 	struct object *o;



More information about the varnish-commit mailing list