[PATCH] Recycle backend connection before setting BOS_FINISHED (take two)

Martin Blix Grydeland martin at varnish-software.com
Mon May 5 16:25:24 CEST 2014


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
---
 bin/varnishd/cache/cache_fetch.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

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);
-- 
1.9.2




More information about the varnish-dev mailing list