[master] 9243e4a Stop VCL's health-polling of backend already when we discard the VCL.

Poul-Henning Kamp phk at varnish-cache.org
Tue May 29 09:37:36 CEST 2012


commit 9243e4a4ba009a2626d33cd3378a73d3b8f91411
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue May 29 07:36:53 2012 +0000

    Stop VCL's health-polling of backend already when we discard the VCL.
    
    Fixes	#1141

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d2162a6..cdd85be 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -691,6 +691,8 @@ void VCA_FailSess(struct worker *w);
 
 /* cache_backend.c */
 void VBE_UseHealth(const struct director *vdi);
+void VBE_DiscardHealth(const struct director *vdi);
+
 
 struct vbc *VDI_GetFd(const struct director *, struct sess *sp);
 int VDI_Healthy(const struct director *, const struct sess *sp);
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 92e74da..6f2ce1f 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -432,6 +432,25 @@ VBE_UseHealth(const struct director *vdi)
  *
  */
 
+void
+VBE_DiscardHealth(const struct director *vdi)
+{
+	struct vdi_simple *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);
+}
+
+/*--------------------------------------------------------------------
+ *
+ */
+
 static struct vbc * __match_proto__(vdi_getfd_f)
 vdi_simple_getfd(const struct director *d, struct sess *sp)
 {
@@ -470,8 +489,6 @@ vdi_simple_fini(const struct director *d)
 	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;
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 6f28507..43ef3cd 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -278,10 +278,10 @@ static void
 ccf_config_discard(struct cli *cli, const char * const *av, void *priv)
 {
 	struct vcls *vcl;
+	int i;
 
 	ASSERT_CLI();
-	(void)av;
-	(void)priv;
+	AZ(priv);
 	vcl = vcl_find(av[2]);
 	if (vcl == NULL) {
 		VCLI_SetResult(cli, CLIS_PARAM);
@@ -299,6 +299,11 @@ ccf_config_discard(struct cli *cli, const char * const *av, void *priv)
 	VSC_C_main->n_vcl_avail--;
 	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);
 }



More information about the varnish-commit mailing list