[master] 4b573e1 VFP_Error() is only for use after vcl_backend_response{} has run.

Poul-Henning Kamp phk at FreeBSD.org
Thu Jan 16 18:09:40 CET 2014


commit 4b573e1e62bd7cc1bde50f5c8722b30fcf9c30ef
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 16 17:09:03 2014 +0000

    VFP_Error() is only for use after vcl_backend_response{} has run.

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 1bdca51..afc3cce 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -130,7 +130,8 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	if (wrk->handling == VCL_RET_ABANDON) {
 		if (bo->req != NULL)
 			vbf_release_req(bo);
-		(void)VFP_Error(bo, "Abandoned in vcl_backend_fetch");
+		HSH_Fail(bo->fetch_objcore);
+		VBO_setstate(bo, BOS_FAILED);
 		return (F_STP_DONE);
 	}
 	assert (wrk->handling == VCL_RET_FETCH);
@@ -148,6 +149,9 @@ make_it_503(struct busyobj *bo)
 	http_SetResp(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed");
 	http_SetHeader(bo->beresp, "Content-Length: 0");
 	http_SetHeader(bo->beresp, "Connection: close");
+	bo->exp.ttl = 0;
+	bo->exp.grace = 0;
+	bo->exp.keep = 0;
 }
 
 /*--------------------------------------------------------------------
@@ -156,7 +160,7 @@ make_it_503(struct busyobj *bo)
 static enum fetch_step
 vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo)
 {
-	int i, do_ims;
+	int i, do_ims, fail;
 	unsigned owid, wid;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -189,11 +193,12 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo)
 
 	if (i) {
 		AZ(bo->vbc);
-		(void)VFP_Error(bo, "Failed to fetch object headers");
 		make_it_503(bo);
+		fail = 1;
 	} else {
 		AN(bo->vbc);
 		http_VSL_log(bo->beresp);
+		fail = 0;
 	}
 
 
@@ -255,8 +260,10 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo)
 		INCOMPL();
 	}
 
-	if (bo->state == BOS_REQ_DONE)
-		VBO_setstate(bo, BOS_COMMITTED);
+	assert(bo->state == BOS_REQ_DONE);
+	VBO_setstate(bo, BOS_COMMITTED);
+	if (fail)
+		(void)VFP_Error(bo, "Fetch failed");
 
 	if (bo->do_esi)
 		bo->do_stream = 0;
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 006768d..f104646 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -61,12 +61,12 @@ VFP_Error(struct busyobj *bo, const char *fmt, ...)
 	va_list ap;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	assert(bo->state >= BOS_COMMITTED);
 	if (bo->state < BOS_FAILED) {
 		va_start(ap, fmt);
 		VSLbv(bo->vsl, SLT_FetchError, fmt, ap);
 		va_end(ap);
-		if (bo->fetch_objcore != NULL)
-			HSH_Fail(bo->fetch_objcore);
+		HSH_Fail(bo->fetch_objcore);
 		VBO_setstate(bo, BOS_FAILED);
 	}
 	return (VFP_ERROR);



More information about the varnish-commit mailing list