[master] d1d7134 Always try to set another thread on the body-fetch job.

Poul-Henning Kamp phk at varnish-cache.org
Mon Mar 12 10:32:17 CET 2012


commit d1d71344524068ad56d170bd29feb719d9a9b902
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 12 09:31:40 2012 +0000

    Always try to set another thread on the body-fetch job.
    
    Slight rearrangement of FetchBody()

diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 1ae5dd7..7df47bb 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -903,18 +903,13 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 	bo = req->busyobj;
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
-#if 1
-	FetchBody(wrk, bo);
-#else
 	bo->fetch_task.func = FetchBody;
 	bo->fetch_task.priv = bo;
-	if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_NO_QUEUE)) {
+	if (Pool_Task(wrk->pool, &bo->fetch_task, POOL_NO_QUEUE))
 		FetchBody(wrk, bo);
-	} else {
-		while (bo->state < BOS_FAILED)
-			(void)usleep(10000);
-	}
-#endif
+
+	while (bo->state < BOS_FAILED)
+		(void)usleep(10000);
 	assert(bo->state >= BOS_FAILED);
 
 	http_Teardown(bo->bereq);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 88bca02..e3bf6dc 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -627,44 +627,43 @@ FetchBody(struct worker *wrk, void *priv)
 		wrk->stats.fetch_failed++;
 		VDI_CloseFd(&bo->vbc);
 		obj->len = 0;
-		bo->stats = NULL;
-		return;
-	}
-
-	assert(bo->state == BOS_FETCHING);
+	} else {
+		assert(bo->state == BOS_FETCHING);
 
-	if (cls == 0 && bo->should_close)
-		cls = 1;
+		if (cls == 0 && bo->should_close)
+			cls = 1;
 
-	VSLb(bo->vsl, SLT_Length, "%zd", obj->len);
+		VSLb(bo->vsl, SLT_Length, "%zd", obj->len);
 
-	{
-	/* Sanity check fetch methods accounting */
-		ssize_t uu;
+		{
+		/* Sanity check fetch methods accounting */
+			ssize_t uu;
 
-		uu = 0;
-		VTAILQ_FOREACH(st, &obj->store, list)
-			uu += st->len;
-		if (bo->do_stream)
-			/* Streaming might have started freeing stuff */
-			assert (uu <= obj->len);
+			uu = 0;
+			VTAILQ_FOREACH(st, &obj->store, list)
+				uu += st->len;
+			if (bo->do_stream)
+				/* Streaming might have started freeing stuff */
+				assert (uu <= obj->len);
 
-		else
-			assert(uu == obj->len);
-	}
+			else
+				assert(uu == obj->len);
+		}
 
-	if (mklen > 0) {
-		http_Unset(obj->http, H_Content_Length);
-		http_PrintfHeader(obj->http, "Content-Length: %zd", obj->len);
-	}
+		if (mklen > 0) {
+			http_Unset(obj->http, H_Content_Length);
+			http_PrintfHeader(obj->http,
+			    "Content-Length: %zd", obj->len);
+		}
 
-	bo->state = BOS_FINISHED;
+		bo->state = BOS_FINISHED;
 
-	if (cls)
-		VDI_CloseFd(&bo->vbc);
-	else
-		VDI_RecycleFd(&bo->vbc);
+		if (cls)
+			VDI_CloseFd(&bo->vbc);
+		else
+			VDI_RecycleFd(&bo->vbc);
 
+	}
 	bo->stats = NULL;
 }
 



More information about the varnish-commit mailing list