[experimental-ims] f9e413c Don't assert if we fail to get storage in VFP_Begin()

Poul-Henning Kamp phk at FreeBSD.org
Thu Dec 18 10:27:40 CET 2014


commit f9e413c77249b0b6c407c087836a1cd80d72d1ab
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Mar 5 11:27:37 2012 +0000

    Don't assert if we fail to get storage in VFP_Begin()
    
    Fixes	#1100

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 1313bc1..1f146d0 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -76,13 +76,16 @@ FetchError(struct busyobj *bo, const char *error)
  * VFP method functions
  */
 
-static void
+static int
 VFP_Begin(struct busyobj *bo, size_t estimate)
 {
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	AN(bo->vfp);
 
 	bo->vfp->begin(bo, estimate);
+	if (bo->fetch_failed)
+		return (-1);
+	return (0);
 }
 
 static int
@@ -146,7 +149,6 @@ vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 	ssize_t l, wl;
 	struct storage *st;
 
-	AZ(bo->fetch_failed);
 	while (bytes > 0) {
 		st = FetchStorage(bo, 0);
 		if (st == NULL)
@@ -575,22 +577,25 @@ FetchBody(struct worker *wrk, struct busyobj *bo)
 		break;
 	case BS_LENGTH:
 		cl = fetch_number(bo->h_content_length, 10);
-		VFP_Begin(bo, cl > 0 ? cl : 0);
-		cls = fetch_straight(bo, htc, cl);
+		cls = VFP_Begin(bo, cl > 0 ? cl : 0);
+		if (!cls)
+			cls = fetch_straight(bo, htc, cl);
 		mklen = 1;
 		if (VFP_End(bo))
 			cls = -1;
 		break;
 	case BS_CHUNKED:
-		VFP_Begin(bo, cl);
-		cls = fetch_chunked(bo, htc);
+		cls = VFP_Begin(bo, cl);
+		if (!cls)
+			cls = fetch_chunked(bo, htc);
 		mklen = 1;
 		if (VFP_End(bo))
 			cls = -1;
 		break;
 	case BS_EOF:
-		VFP_Begin(bo, cl);
-		cls = fetch_eof(bo, htc);
+		cls = VFP_Begin(bo, cl);
+		if (!cls)
+			cls = fetch_eof(bo, htc);
 		mklen = 1;
 		if (VFP_End(bo))
 			cls = -1;
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 2689cc8..c5f49de 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -213,7 +213,8 @@ pan_busyobj(const struct busyobj *bo)
 	if (bo->do_esi)		VSB_printf(pan_vsp, "    do_esi\n");
 	if (bo->do_stream)	VSB_printf(pan_vsp, "    do_stream\n");
 	if (bo->should_close)	VSB_printf(pan_vsp, "    should_close\n");
-	VSB_printf(pan_vsp, "    bodystatus = %d,\n", bo->body_status);
+	VSB_printf(pan_vsp, "    bodystatus = %d (%s),\n",
+	    bo->body_status, body_status(bo->body_status));
 	VSB_printf(pan_vsp, "    },\n");
 	if (VALID_OBJ(bo->vbc, BACKEND_MAGIC))
 		pan_vbc(bo->vbc);



More information about the varnish-commit mailing list