[master] 7bbc60f Untangle cnt_error() entrance criteria:

Poul-Henning Kamp phk at varnish-cache.org
Mon Jan 23 21:03:54 CET 2012


commit 7bbc60f7bf32b0b6e3274445b900caaa20766cdf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jan 23 20:03:08 2012 +0000

    Untangle cnt_error() entrance criteria:
    
    We should never come in with a busyobj or obj.
    
    Always allocate obj from Transient storage.

diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 28ef0bf..0c08dd2 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -488,32 +488,25 @@ cnt_error(struct sess *sp, struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
+	AZ(req->objcore);
+	AZ(req->obj);
+	AZ(wrk->busyobj);
+	wrk->busyobj = VBO_GetBusyObj(wrk);
+	req->obj = STV_NewObject(wrk, TRANSIENT_STORAGE,
+	    cache_param->http_resp_size,
+	    (uint16_t)cache_param->http_max_hdr);
 	if (req->obj == NULL) {
-		HSH_Prealloc(sp);
-		AZ(wrk->busyobj);
-		wrk->busyobj = VBO_GetBusyObj(wrk);
-		req->obj = STV_NewObject(wrk, NULL, cache_param->http_resp_size,
-		     (uint16_t)cache_param->http_max_hdr);
-		if (req->obj == NULL)
-			req->obj = STV_NewObject(wrk, TRANSIENT_STORAGE,
-			    cache_param->http_resp_size,
-			    (uint16_t)cache_param->http_max_hdr);
-		if (req->obj == NULL) {
-			req->doclose = "Out of objects";
-			req->director = NULL;
-			http_Setup(wrk->busyobj->beresp, NULL);
-			http_Setup(wrk->busyobj->bereq, NULL);
-			sp->step = STP_DONE;
-			return(0);
-		}
-		AN(req->obj);
-		req->obj->xid = req->xid;
-		req->obj->exp.entered = sp->t_req;
-	} else {
-		CHECK_OBJ_NOTNULL(wrk->busyobj, BUSYOBJ_MAGIC);
-		/* XXX: Null the headers ? */
+		req->doclose = "Out of objects";
+		req->director = NULL;
+		http_Setup(wrk->busyobj->beresp, NULL);
+		http_Setup(wrk->busyobj->bereq, NULL);
+		sp->step = STP_DONE;
+		return(0);
 	}
 	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
+	req->obj->xid = req->xid;
+	req->obj->exp.entered = sp->t_req;
+
 	h = req->obj->http;
 
 	if (req->err_code < 100 || req->err_code > 999)



More information about the varnish-commit mailing list