[master] 2e3149b Make sure that VFP_Close is always called if and only if VFP_Open was called

Martin Blix Grydeland martin at varnish-software.com
Mon Aug 1 13:33:07 CEST 2016


commit 2e3149b24b21890effbfcc3b8aeba3db2ea06e5f
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Thu May 19 16:06:20 2016 +0200

    Make sure that VFP_Close is always called if and only if VFP_Open was
    called
    
    For some (out of workspace or stevedore allocationi failure) errors
    VFP_Close would fail to be called when ending up not retrying the
    fetch. This would then potentially leak VFP entry context data like
    gzip buffers. Fix this by always calling VFP_Close() when changing
    fetch state when VFP_Open() has been called.
    
    Also VFP_Close() would for some retries be called twice, causing
    double accounting log records print out. This happens when a late
    error is caught and streaming is disabled, allowing a retry to be
    attempted. Fix this by not unconditionally calling VFP_Close() in the
    error state.

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 37f0346..ac0a356 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -237,8 +237,6 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
 	bo->do_stream = 1;
 
 	/* reset fetch processors */
-	vfc->failed = 0;
-	VFP_Close(vfc);
 	VFP_Setup(vfc);
 
 	// XXX: BereqEnd + BereqAcct ?
@@ -639,6 +637,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	if (vbf_beresp2obj(bo)) {
 		(void)VFP_Error(bo->vfc, "Could not get storage");
 		bo->htc->doclose = SC_RX_BODY;
+		VFP_Close(bo->vfc);
 		VDI_Finish(bo->wrk, bo);
 		return (F_STP_ERROR);
 	}
@@ -662,6 +661,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	    VDI_GetBody(bo->wrk, bo) != 0) {
 		(void)VFP_Error(bo->vfc,
 		    "GetBody failed - workspace_backend overflow?");
+		VFP_Close(bo->vfc);
 		bo->htc->doclose = SC_OVERLOAD;
 		VDI_Finish(bo->wrk, bo);
 		return (F_STP_ERROR);



More information about the varnish-commit mailing list