[master] d60d80d Move responsibility for discarding backend probes.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jan 19 13:57:08 CET 2015
commit d60d80d36fbcf09a44bdd5cff88ea02011f185e7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 19 12:56:45 2015 +0000
Move responsibility for discarding backend probes.
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 113342b..4f8834d 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -102,25 +102,6 @@ VBE_UseHealth(const struct director *vdi)
}
/*--------------------------------------------------------------------
- *
- */
-
-void
-VBE_DiscardHealth(const struct director *vdi)
-{
- struct vbe_dir *vs;
-
- ASSERT_CLI();
-
- if (strcmp(vdi->name, "simple"))
- return;
- CAST_OBJ_NOTNULL(vs, vdi->priv, VDI_SIMPLE_MAGIC);
- if (vs->vrt->probe == NULL)
- return;
- VBP_Remove(vs->backend, vs->vrt->probe);
-}
-
-/*--------------------------------------------------------------------
* Get a connection to the backend
*/
@@ -294,39 +275,49 @@ vbe_dir_getbody(const struct director *d, struct worker *wrk,
/*--------------------------------------------------------------------*/
+static void
+vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo)
+{
+ int i;
+
+ CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+ CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+
+ i = vbe_dir_getfd(d, bo);
+ V1P_Process(req, bo, i);
+ vbe_dir_finish(d, bo->wrk, bo);
+}
+
+/*--------------------------------------------------------------------*/
+
void
-VRT_fini_vbe(VRT_CTX, struct director *d)
+VRT_fini_vbe(VRT_CTX, struct director **dp, const struct vrt_backend *vrt)
{
struct vbe_dir *vs;
+ struct director *d;
ASSERT_CLI();
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
+ AN(dp);
+ (void)vrt;
+
+ d = *dp;
+ *dp = NULL;
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
+ if (vs->vrt->probe != NULL)
+ VBP_Remove(vs->backend, vs->vrt->probe);
+
VBE_DropRefVcl(vs->backend);
free(vs->dir.vcl_name);
vs->dir.magic = 0;
FREE_OBJ(vs);
- d->priv = NULL;
}
-static void
-vbe_dir_http1pipe(const struct director *d, struct req *req, struct busyobj *bo)
-{
- int i;
-
- CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
-
- i = vbe_dir_getfd(d, bo);
- V1P_Process(req, bo, i);
- vbe_dir_finish(d, bo->wrk, bo);
-}
void
-VRT_init_vbe(VRT_CTX, struct director **bp, int idx,
- const struct vrt_backend *vrt)
+VRT_init_vbe(VRT_CTX, struct director **bp, const struct vrt_backend *vrt)
{
struct vbe_dir *vs;
@@ -351,5 +342,5 @@ VRT_init_vbe(VRT_CTX, struct director **bp, int idx,
if (vs->vrt->probe != NULL)
VBP_Insert(vs->backend, vs->vrt->probe, vs->vrt->hosthdr);
- bp[idx] = &vs->dir;
+ * bp = &vs->dir;
}
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 63806ec..32f3b8d 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -98,7 +98,6 @@ struct vbc {
/* cache_backend.c */
void VBE_UseHealth(const struct director *vdi);
-void VBE_DiscardHealth(const struct director *vdi);
/* cache_backend_cfg.c */
void VBE_DropRefConn(struct backend *, const struct acct_bereq *);
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index c6ea472..08f996b 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -330,7 +330,6 @@ static void
ccf_config_discard(struct cli *cli, const char * const *av, void *priv)
{
struct vcls *vcl;
- int i;
ASSERT_CLI();
AZ(priv);
@@ -353,10 +352,6 @@ ccf_config_discard(struct cli *cli, const char * const *av, void *priv)
vcl->conf->discard = 1;
Lck_Unlock(&vcl_mtx);
- /* Tickle this VCL's backends to give up health polling */
- for(i = 1; i < vcl->conf->ndirector; i++)
- VBE_DiscardHealth(vcl->conf->director[i]);
-
if (vcl->conf->busy == 0)
VCL_Nuke(vcl);
}
diff --git a/include/vrt.h b/include/vrt.h
index bc4a73d..09e2b52 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -225,8 +225,8 @@ void VRT_Rollback(VRT_CTX, const struct http *);
void VRT_synth_page(VRT_CTX, const char *, ...);
/* Backend related */
-void VRT_init_vbe(VRT_CTX, struct director **, int idx, const struct vrt_backend *);
-void VRT_fini_vbe(VRT_CTX, struct director *);
+void VRT_init_vbe(VRT_CTX, struct director **, const struct vrt_backend *);
+void VRT_fini_vbe(VRT_CTX, struct director **, const struct vrt_backend *);
/* Suckaddr related */
int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst);
diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c
index 25b13da..66feb7e 100644
--- a/lib/libvcc/vcc_backend.c
+++ b/lib/libvcc/vcc_backend.c
@@ -423,9 +423,11 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be)
ifp = New_IniFin(tl);
VSB_printf(ifp->ini,
- "\tVRT_init_vbe(ctx, VCL_conf.director,\n"
- "\t VGC_backend_%s, &vgc_dir_priv_%s);", vgcname, vgcname);
- VSB_printf(ifp->fin, "\tVRT_fini_vbe(ctx, VGCDIR(%s));", vgcname);
+ "\tVRT_init_vbe(ctx, &VGCDIR(%s), &vgc_dir_priv_%s);",
+ vgcname, vgcname);
+ VSB_printf(ifp->fin,
+ "\tVRT_fini_vbe(ctx, &VGCDIR(%s), &vgc_dir_priv_%s);",
+ vgcname, vgcname);
tl->ndirector++;
}
More information about the varnish-commit
mailing list