[4.1] e0fd9ba Add a force_fresh parameter to VBT_Get
Dag Haavi Finstad
daghf at varnish-software.com
Mon Nov 27 16:36:09 UTC 2017
commit e0fd9ba67e5234b167214658ba83070cb1b5a3ed
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date: Mon Nov 27 16:26:04 2017 +0100
Add a force_fresh parameter to VBT_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 905bb13..4133359 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -91,7 +91,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);
- vc = VBT_Get(bp->tcp_pool, tmod, bp, wrk);
+ vc = VBT_Get(bp->tcp_pool, tmod, bp, wrk, 0);
if (vc == NULL) {
// XXX: Per backend stats ?
VSC_C_main->backend_fail++;
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 0bc73ed..d52f2da 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -126,7 +126,7 @@ int VBT_Open(const struct tcp_pool *tp, double tmo, const struct suckaddr **sa);
void VBT_Recycle(const struct worker *, struct tcp_pool *, struct vbc **);
void VBT_Close(struct tcp_pool *tp, struct vbc **vbc);
struct vbc *VBT_Get(struct tcp_pool *, double tmo, const struct backend *,
- struct worker *);
+ struct worker *, unsigned force_fresh);
void VBT_Wait(struct worker *, struct vbc *);
/* cache_vcl.c */
diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c
index 8e9b660..882d087 100644
--- a/bin/varnishd/cache/cache_backend_tcp.c
+++ b/bin/varnishd/cache/cache_backend_tcp.c
@@ -354,7 +354,7 @@ VBT_Close(struct tcp_pool *tp, struct vbc **vbcp)
struct vbc *
VBT_Get(struct tcp_pool *tp, double tmo, const struct backend *be,
- struct worker *wrk)
+ struct worker *wrk, unsigned force_fresh)
{
struct vbc *vbc;
@@ -365,7 +365,7 @@ VBT_Get(struct tcp_pool *tp, double tmo, const struct backend *be,
Lck_Lock(&tp->mtx);
vbc = VTAILQ_FIRST(&tp->connlist);
CHECK_OBJ_ORNULL(vbc, VBC_MAGIC);
- if (vbc == NULL || vbc->state == VBC_STATE_STOLEN)
+ if (force_fresh || vbc == NULL || vbc->state == VBC_STATE_STOLEN)
vbc = NULL;
else {
assert(vbc->tcp_pool == tp);
More information about the varnish-commit
mailing list