[master] d770a10 Resource cleanup in cnt_error() when Transient is full.

Martin Blix Grydeland martin at varnish-cache.org
Tue Mar 19 15:43:18 CET 2013


commit d770a105b5587c7b402a1dff1629b78eaa82b0e9
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Mon Mar 18 15:25:42 2013 +0100

    Resource cleanup in cnt_error() when Transient is full.
    
    Fixes: #1283

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index db906ec..b680605 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -682,7 +682,8 @@ HSH_Deref(struct dstat *ds, struct objcore *oc, struct object **oo)
 
 		BAN_DestroyObj(oc);
 		AZ(oc->ban);
-	}
+	} else
+		AZ(oc->refcnt);
 
 	if (oc->methods != NULL) {
 		oc_freeobj(oc);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index b2bdd50..a7f8778 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -280,11 +280,16 @@ cnt_error(struct worker *wrk, struct req *req)
 	if (req->obj == NULL) {
 		req->doclose = SC_OVERLOAD;
 		req->director = NULL;
+		AZ(HSH_Deref(&wrk->stats, req->objcore, NULL));
+		req->objcore = NULL;
 		http_Teardown(bo->beresp);
 		http_Teardown(bo->bereq);
+		VBO_DerefBusyObj(wrk, &req->busyobj);
+		AZ(req->busyobj);
 		return (REQ_FSM_DONE);
 	}
 	CHECK_OBJ_NOTNULL(req->obj, OBJECT_MAGIC);
+	AZ(req->objcore);
 	req->obj->vxid = bo->vsl->wid;
 	req->obj->exp.entered = req->t_req;
 
diff --git a/bin/varnishtest/tests/r01283.vtc b/bin/varnishtest/tests/r01283.vtc
new file mode 100644
index 0000000..9283209
--- /dev/null
+++ b/bin/varnishtest/tests/r01283.vtc
@@ -0,0 +1,44 @@
+varnishtest "#1283 - Test failure to allocate object for error (transient full)"
+
+server s1 {
+	rxreq
+	txresp -bodylen 1048000
+} -start
+
+varnish v1 -arg "-p nuke_limit=0" -storage "-sTransient=malloc,1m" -vcl+backend {
+	sub vcl_recv {
+		if (req.http.x-do-error) {
+			error 500;
+		}
+	}
+	sub vcl_fetch {
+		set beresp.storage = "Transient";
+	}
+} -start
+
+client c1 {
+	# Fill transient
+	txreq
+	rxresp
+	expect resp.status == 200
+} -run
+
+varnish v1 -expect SMA.Transient.g_bytes > 1048000
+varnish v1 -expect SMA.Transient.g_space < 200
+varnish v1 -expect SMA.Transient.c_fail == 0
+
+client c1 {
+	# Trigger vcl_error. Don't wait for reply as Varnish will not send one
+	# due to Transient full
+	txreq -hdr "X-Do-Error: true"
+	delay 1
+} -run
+
+varnish v1 -expect SMA.Transient.c_fail == 1
+
+client c1 {
+	# Check that Varnish is still alive
+	txreq
+	rxresp
+	expect resp.status == 200
+} -run



More information about the varnish-commit mailing list