[master] fec6289 Eliminate vbc->backend pointer
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jun 24 22:45:12 CEST 2015
commit fec6289ee98075d5b659e92425752f4b74e6544e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jun 24 18:10:12 2015 +0000
Eliminate vbc->backend pointer
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index ca40b75..7602155 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -119,7 +119,6 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
}
assert(vc->fd >= 0);
- vc->backend = bp;
AN(vc->addr);
Lck_Lock(&bp->mtx);
@@ -173,8 +172,6 @@ vbe_dir_finish(const struct director *d, struct worker *wrk,
return;
if (bo->htc->vbc->state != VBC_STATE_USED)
VBT_Wait(wrk, bo->htc->vbc);
- CHECK_OBJ_NOTNULL(bo->htc->vbc->backend, BACKEND_MAGIC);
- bo->htc->vbc->backend = NULL;
if (bo->htc->doclose != SC_NULL) {
VSLb(bo->vsl, SLT_BackendClose, "%d %s", bo->htc->vbc->fd,
bp->display_name);
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index bd812ab..d7cb7d7 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -99,7 +99,6 @@ struct vbc {
struct waited waited[1];
struct tcp_pool *tcp_pool;
- struct backend *backend;
pthread_cond_t *cond;
};
@@ -126,7 +125,7 @@ void VBT_Rel(struct tcp_pool **tpp);
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, struct backend *,
+struct vbc *VBT_Get(struct tcp_pool *, double tmo, const struct backend *,
struct worker *);
void VBT_Wait(struct worker *, struct vbc *);
diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c
index a307e71..05fd232 100644
--- a/bin/varnishd/cache/cache_backend_tcp.c
+++ b/bin/varnishd/cache/cache_backend_tcp.c
@@ -95,7 +95,6 @@ tcp_handle(struct waited *w, enum wait_event ev, double now)
case VBC_STATE_STOLEN:
vbc->state = VBC_STATE_USED;
VTAILQ_REMOVE(&tp->connlist, vbc, list);
- CHECK_OBJ_NOTNULL(vbc->backend, BACKEND_MAGIC);
AN(vbc->cond);
AZ(pthread_cond_signal(vbc->cond));
break;
@@ -262,7 +261,6 @@ VBT_Recycle(const struct worker *wrk, struct tcp_pool *tp, struct vbc **vbcp)
assert(vbc->state == VBC_STATE_USED);
assert(vbc->fd > 0);
- AZ(vbc->backend);
Lck_Lock(&tp->mtx);
tp->n_used--;
@@ -321,7 +319,6 @@ VBT_Close(struct tcp_pool *tp, struct vbc **vbcp)
assert(vbc->state == VBC_STATE_USED);
assert(vbc->fd > 0);
- AZ(vbc->backend);
Lck_Lock(&tp->mtx);
tp->n_used--;
@@ -344,7 +341,8 @@ VBT_Close(struct tcp_pool *tp, struct vbc **vbcp)
*/
struct vbc *
-VBT_Get(struct tcp_pool *tp, double tmo, struct backend *be, struct worker *wrk)
+VBT_Get(struct tcp_pool *tp, double tmo, const struct backend *be,
+ struct worker *wrk)
{
struct vbc *vbc;
@@ -355,7 +353,7 @@ VBT_Get(struct tcp_pool *tp, double tmo, struct backend *be, struct worker *wrk)
Lck_Lock(&tp->mtx);
vbc = VTAILQ_FIRST(&tp->connlist);
CHECK_OBJ_ORNULL(vbc, VBC_MAGIC);
- if (vbc == NULL || vbc->backend != NULL)
+ if (vbc == NULL || vbc->state == VBC_STATE_STOLEN)
vbc = NULL;
else {
assert(vbc->tcp_pool == tp);
@@ -365,7 +363,6 @@ VBT_Get(struct tcp_pool *tp, double tmo, struct backend *be, struct worker *wrk)
tp->n_conn--;
VSC_C_main->backend_reuse += 1;
vbc->state = VBC_STATE_STOLEN;
- vbc->backend = be;
vbc->cond = &wrk->cond;
}
tp->n_used++; // Opening mostly works
@@ -379,7 +376,6 @@ VBT_Get(struct tcp_pool *tp, double tmo, struct backend *be, struct worker *wrk)
INIT_OBJ(vbc->waited, WAITED_MAGIC);
vbc->state = VBC_STATE_USED;
vbc->tcp_pool = tp;
- vbc->backend = be;
vbc->fd = VBT_Open(tp, tmo, &vbc->addr);
if (vbc->fd < 0)
FREE_OBJ(vbc);
@@ -401,7 +397,6 @@ VBT_Wait(struct worker *wrk, struct vbc *vbc)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(vbc, VBC_MAGIC);
- CHECK_OBJ_NOTNULL(vbc->backend, BACKEND_MAGIC);
tp = vbc->tcp_pool;
CHECK_OBJ_NOTNULL(tp, TCP_POOL_MAGIC);
assert(vbc->cond == &wrk->cond);
More information about the varnish-commit
mailing list