[4.1] 4c7c283 Polish admin_health stuff a little bit

Poul-Henning Kamp phk at FreeBSD.org
Fri Sep 4 15:54:49 CEST 2015


commit 4c7c28382d01efb27455fd85ca7dadd2dea26a13
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jul 7 21:17:26 2015 +0000

    Polish admin_health stuff a little bit

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 522fad2..0cfbd40 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1053,7 +1053,7 @@ void VCL_Ref(struct vcl *);
 void VCL_Refresh(struct vcl **);
 void VCL_Rel(struct vcl **);
 void VCL_AddBackend(struct vcl *, struct backend *);
-void VCL_DelBackend(struct vcl *, struct backend *);
+void VCL_DelBackend(struct vcl *, const struct backend *);
 const char *VCL_Return_Name(unsigned);
 
 #define VCL_MET_MAC(l,u,b) \
diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 79c4ae2..bf7b537 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -55,27 +55,6 @@
 	} while (0)
 
 /*--------------------------------------------------------------------
- * Test if backend is healthy and report when it last changed
- */
-
-unsigned
-VBE_Healthy(const struct backend *backend, double *changed)
-{
-	CHECK_OBJ_NOTNULL(backend, BACKEND_MAGIC);
-
-	if (changed != NULL)
-		*changed = backend->health_changed;
-
-	if (backend->admin_health == vbe_ah_probe && !backend->healthy)
-		return (0);
-
-	if (backend->admin_health == vbe_ah_sick)
-		return (0);
-
-	return (1);
-}
-
-/*--------------------------------------------------------------------
  * Get a connection to the backend
  */
 
diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h
index 9443ac2..06f50e1 100644
--- a/bin/varnishd/cache/cache_backend.h
+++ b/bin/varnishd/cache/cache_backend.h
@@ -46,10 +46,6 @@ struct tcp_pool;
  * An instance of a backend from a VCL program.
  */
 
-extern const char * const vbe_ah_healthy;
-extern const char * const vbe_ah_sick;
-extern const char * const vbe_ah_probe;
-
 struct backend {
 	unsigned		magic;
 #define BACKEND_MAGIC		0x64c4c7c6
diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c
index a22af3c..aba8e8b 100644
--- a/bin/varnishd/cache/cache_backend_cfg.c
+++ b/bin/varnishd/cache/cache_backend_cfg.c
@@ -50,9 +50,9 @@
 static VTAILQ_HEAD(, backend) backends = VTAILQ_HEAD_INITIALIZER(backends);
 static struct lock backends_mtx;
 
-const char * const vbe_ah_healthy	= "healthy";
-const char * const vbe_ah_sick		= "sick";
-const char * const vbe_ah_probe		= "probe";
+static const char * const vbe_ah_healthy	= "healthy";
+static const char * const vbe_ah_sick		= "sick";
+static const char * const vbe_ah_probe		= "probe";
 
 /*--------------------------------------------------------------------
  * Create a new static or dynamic director::backend instance.
@@ -205,7 +205,7 @@ vbe_str2adminhealth(const char *wstate)
 {
 
 #define FOO(x, y) if (strcasecmp(wstate, #x) == 0) return (vbe_ah_##y)
-	FOO(healthy, 	healthy);
+	FOO(healthy,	healthy);
 	FOO(sick,	sick);
 	FOO(probe,	probe);
 	FOO(auto,	probe);
@@ -213,6 +213,30 @@ vbe_str2adminhealth(const char *wstate)
 #undef FOO
 }
 
+/*--------------------------------------------------------------------
+ * Test if backend is healthy and report when it last changed
+ */
+
+unsigned
+VBE_Healthy(const struct backend *backend, double *changed)
+{
+	CHECK_OBJ_NOTNULL(backend, BACKEND_MAGIC);
+
+	if (changed != NULL)
+		*changed = backend->health_changed;
+
+	if (backend->admin_health == vbe_ah_probe)
+		return (backend->healthy);
+
+	if (backend->admin_health == vbe_ah_sick)
+		return (0);
+
+	if (backend->admin_health == vbe_ah_healthy)
+		return (1);
+
+	WRONG("Wrong admin health");
+}
+
 /*---------------------------------------------------------------------
  * A general function for finding backends and doing things with them.
  *
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 3ab89ff..0a5eac9 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -203,7 +203,7 @@ VCL_AddBackend(struct vcl *vcl, struct backend *be)
 }
 
 void
-VCL_DelBackend(struct vcl *vcl, struct backend *be)
+VCL_DelBackend(struct vcl *vcl, const struct backend *be)
 {
 	CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC);
 	CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC);



More information about the varnish-commit mailing list