[master] 7fdf6d0 Fix out of storage condition when failing to allocate transient synth

Martin Blix Grydeland martin at varnish-software.com
Mon Jun 29 17:00:15 CEST 2015


commit 7fdf6d09fbf30c53f51e9da085fb1a3a8d1d5cc5
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Mon Jun 29 16:38:08 2015 +0200

    Fix out of storage condition when failing to allocate transient synth
    
    Do not assert if the transient stevedore fails to provide storage for
    the synth body.
    
    Log an SLT_Error record when failing on out of storage.
    
    Document that synth objects are created on transient storage.
    
    Fix an objcore leak that would come if we failed to create the object.
    
    Fixes: #1740

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 9c4861f..b0fe1e7 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -223,6 +223,8 @@ cnt_synth(struct worker *wrk, struct req *req)
 	struct http *h;
 	double now;
 	struct vsb *synth_body;
+	ssize_t sz, szl;
+	uint8_t *ptr;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
@@ -269,22 +271,25 @@ cnt_synth(struct worker *wrk, struct req *req)
 	req->objcore = HSH_Private(wrk);
 	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
 	if (STV_NewObject(req->objcore, wrk, TRANSIENT_STORAGE, 1024)) {
-		ssize_t sz, szl;
-		uint8_t *ptr;
-
 		szl = VSB_len(synth_body);
 		assert(szl >= 0);
-		if (szl > 0) {
-			sz = szl;
-			AN(ObjGetSpace(wrk, req->objcore, &sz, &ptr));
-			assert(sz >= szl);
+	} else
+		szl = -1;
+	if (szl > 0) {
+		sz = szl;
+		if (ObjGetSpace(wrk, req->objcore, &sz, &ptr) && sz >= szl) {
 			memcpy(ptr, VSB_data(synth_body), szl);
 			ObjExtend(wrk, req->objcore, szl);
-		}
-
-		cnt_vdp(req, NULL);
-		(void)HSH_DerefObjCore(wrk, &req->objcore);
+		} else
+			szl = -1;
 	}
+	if (szl < 0) {
+		VSLb(req->vsl, SLT_Error, "Could not get storage");
+		req->doclose = SC_OVERLOAD;
+	} else
+		cnt_vdp(req, NULL);
+
+	(void)HSH_DerefObjCore(wrk, &req->objcore);
 	VSB_delete(synth_body);
 
 	VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst
index 5d08d1e..9782313 100644
--- a/doc/sphinx/users-guide/storage-backends.rst
+++ b/doc/sphinx/users-guide/storage-backends.rst
@@ -132,8 +132,9 @@ previously banned objects to reappear.
 Transient Storage
 -----------------
 
-If you name any of your storage backend "Transient" it will be
-used for transient (short lived) objects. By default Varnish
+If you name any of your storage backend "Transient" it will be used
+for transient (short lived) objects. This includes the temporary
+objects created when returning a synthetic object. By default Varnish
 would use an unlimited malloc backend for this.
 
 .. XXX: Is this another paramater? In that case handled in the same manner as above? benc



More information about the varnish-commit mailing list