[master] fa04c3d Add a force_fresh parameter to VTP_Get
Dag Haavi Finstad
daghf at varnish-software.com
Mon Nov 20 10:24:10 UTC 2017
commit fa04c3d44d82c2617c985483d1e449a2312bda15
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date: Mon Nov 13 16:28:27 2017 +0100
Add a force_fresh parameter to VTP_Get
Passing a nonzero value will force a fresh backend connection.
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 31f77e9..d0fa5bb 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -112,7 +112,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
bo->htc->doclose = SC_NULL;
FIND_TMO(connect_timeout, tmod, bo, bp);
- vtp = VTP_Get(bp->tcp_pool, tmod, wrk);
+ vtp = VTP_Get(bp->tcp_pool, tmod, wrk, 0);
if (vtp == NULL) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: fail", bp->director->display_name);
diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c
index 04ea7e2..943cdd1 100644
--- a/bin/varnishd/cache/cache_tcp_pool.c
+++ b/bin/varnishd/cache/cache_tcp_pool.c
@@ -366,7 +366,8 @@ VTP_Close(struct vtp **vtpp)
*/
struct vtp *
-VTP_Get(struct tcp_pool *tp, double tmo, struct worker *wrk)
+VTP_Get(struct tcp_pool *tp, double tmo, struct worker *wrk,
+ unsigned force_fresh)
{
struct vtp *vtp;
@@ -376,7 +377,7 @@ VTP_Get(struct tcp_pool *tp, double tmo, struct worker *wrk)
Lck_Lock(&tp->mtx);
vtp = VTAILQ_FIRST(&tp->connlist);
CHECK_OBJ_ORNULL(vtp, VTP_MAGIC);
- if (vtp == NULL || vtp->state == VTP_STATE_STOLEN)
+ if (force_fresh || vtp == NULL || vtp->state == VTP_STATE_STOLEN)
vtp = NULL;
else {
assert(vtp->tcp_pool == tp);
diff --git a/bin/varnishd/cache/cache_tcp_pool.h b/bin/varnishd/cache/cache_tcp_pool.h
index 11b0f82..4dbc12f 100644
--- a/bin/varnishd/cache/cache_tcp_pool.h
+++ b/bin/varnishd/cache/cache_tcp_pool.h
@@ -85,7 +85,8 @@ void VTP_Recycle(const struct worker *, struct vtp **);
* Recycle an open connection.
*/
-struct vtp *VTP_Get(struct tcp_pool *, double tmo, struct worker *);
+struct vtp *VTP_Get(struct tcp_pool *, double tmo, struct worker *,
+ unsigned force_fresh);
/*
* Get a (possibly) recycled connection.
*/
More information about the varnish-commit
mailing list