[4.1] 74c49a2 Eliminate the backend refcount, n_conn serves as refcount and is all we need.
Poul-Henning Kamp
phk at FreeBSD.org
Fri Sep 4 15:54:50 CEST 2015
commit 74c49a2e89c24312fda5aefc7b690271bdc47ffa
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Sun Jul 12 08:19:59 2015 +0000
Eliminate the backend refcount, n_conn serves as refcount and is all
we need.
Send warm dynamic backends "COLD" event before deleting them.
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 611c089..0591ec7 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -103,7 +103,6 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo)
AN(vc->addr);
Lck_Lock(&bp->mtx);
- bp->refcount++;
bp->n_conn++;
bp->vsc->conn++;
Lck_Unlock(&bp->mtx);
@@ -330,7 +329,7 @@ vbe_panic(const struct director *d, struct vsb *vsb)
VSB_printf(vsb, " health=%s, admin_health=%s",
bp->healthy ? "healthy" : "sick", bp->admin_health);
VSB_printf(vsb, ", changed=%.1f\n", bp->health_changed);
- VSB_printf(vsb, " refcount = %d\n", bp->refcount);
+ VSB_printf(vsb, " n_conn = %u\n", bp->n_conn);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 97e70c1..49fc110 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -52,7 +52,6 @@ struct backend {
VTAILQ_ENTRY(backend) list;
VTAILQ_ENTRY(backend) vcl_list;
- int refcount;
struct lock mtx;
VRT_BACKEND_FIELDS()
@@ -129,4 +128,4 @@ void VBT_Wait(struct worker *, struct vbc *);
/* cache_vcl.c */
void VCL_AddBackend(struct vcl *, struct backend *);
-void VCL_DelBackend(const struct backend *);
+void VCL_DelBackend(struct backend *);
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index a9199d3..8b89625 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -70,13 +70,11 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vrt, VRT_BACKEND_MAGIC);
-
assert(vrt->ipv4_suckaddr != NULL || vrt->ipv6_suckaddr != NULL);
vcl = ctx->vcl;
AN(vcl);
AN(vrt->vcl_name);
- assert(vrt->ipv4_suckaddr != NULL || vrt->ipv6_suckaddr != NULL);
/* Create new backend */
ALLOC_OBJ(b, BACKEND_MAGIC);
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index b450361..c10d949 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -205,7 +205,7 @@ VCL_AddBackend(struct vcl *vcl, struct backend *be)
}
void
-VCL_DelBackend(const struct backend *be)
+VCL_DelBackend(struct backend *be)
{
struct vcl *vcl;
@@ -215,6 +215,8 @@ VCL_DelBackend(const struct backend *be)
Lck_Lock(&vcl_mtx);
VTAILQ_REMOVE(&vcl->backend_list, be, vcl_list);
Lck_Unlock(&vcl_mtx);
+ if (vcl->temp == vcl_temp_warm)
+ VBE_Event(be, VCL_EVENT_COLD);
}
static void
More information about the varnish-commit
mailing list