[master] 2baa875 Recycle backend connection before setting BOS_FINISHED (take two)

Martin Blix Grydeland martin at varnish-software.com
Tue May 6 10:46:02 CEST 2014


commit 2baa8754fe4a0fc3e4efc9865bddc265fae13690
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Mon May 5 14:06:40 2014 +0200

    Recycle backend connection before setting BOS_FINISHED (take two)
    
    This to give predictable backend reuse behavior for varnishtest,
    making the test cases non-racy.
    
    2nd version of this patch. This version will only deal with recyclable
    backend connections before BOS_FINISHED, leaving the slower close path
    to the clean up code that is run after the BOS_FINISHED state.
    
    Fixes: #1491

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index dded999..ac4c478 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -548,6 +548,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 		HSH_Unbusy(&wrk->stats, obj->objcore);
 	}
 	VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk));
+
+	/* Recycle the backend connection before setting BOS_FINISHED to
+	   give predictable backend reuse behavior for varnishtest */
+	if (bo->vbc != NULL && !(bo->should_close)) {
+		VDI_RecycleFd(&bo->vbc, &bo->acct);
+		AZ(bo->vbc);
+	}
+
 	VBO_setstate(bo, BOS_FINISHED);
 	return (F_STP_DONE);
 }
@@ -639,6 +647,14 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	assert(al == bo->ims_obj->len);
 	assert(obj->len == al);
 	EXP_Rearm(bo->ims_obj, bo->ims_obj->exp.t_origin, 0, 0, 0);
+
+	/* Recycle the backend connection before setting BOS_FINISHED to
+	   give predictable backend reuse behavior for varnishtest */
+	if (bo->vbc != NULL && !(bo->should_close)) {
+		VDI_RecycleFd(&bo->vbc, &bo->acct);
+		AZ(bo->vbc);
+	}
+
 	VBO_setstate(bo, BOS_FINISHED);
 	VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk));
 	return (F_STP_DONE);



More information about the varnish-commit mailing list