Blob Blame History Raw
From 6f18ff4f0a06015691b25cb91bf4c6dccec5cc89 Mon Sep 17 00:00:00 2001
From: Quentin Armitage <quentin@armitage.org.uk>
Date: Sun, 16 Jul 2017 10:00:20 +0100
Subject: [PATCH] Make a couple of checker variables non global

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
---
 keepalived/check/check_api.c    |  4 ++--
 keepalived/check/check_daemon.c | 11 ++++++-----
 keepalived/check/ipwrapper.c    | 10 +++++-----
 keepalived/include/check_api.h  |  2 --
 keepalived/include/ipwrapper.h  |  2 +-
 5 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/keepalived/check/check_api.c b/keepalived/check/check_api.c
index 82b0f2df..016850f0 100644
--- a/keepalived/check/check_api.c
+++ b/keepalived/check/check_api.c
@@ -42,9 +42,8 @@
 #include "check_dns.h"
 
 /* Global vars */
-checker_id_t ncheckers = 0;
+static checker_id_t ncheckers;
 list checkers_queue;
-list old_checkers_queue;
 
 /* free checker data */
 static void
@@ -243,6 +242,7 @@ void
 init_checkers_queue(void)
 {
 	checkers_queue = alloc_list(free_checker, dump_checker);
+	ncheckers = 0;
 }
 
 /* release the checkers_queue */
diff --git a/keepalived/check/check_daemon.c b/keepalived/check/check_daemon.c
index 462360e6..85f8bdbd 100644
--- a/keepalived/check/check_daemon.c
+++ b/keepalived/check/check_daemon.c
@@ -108,7 +108,7 @@ stop_check(int status)
 
 /* Daemon init sequence */
 static void
-start_check(void)
+start_check(list old_checkers_queue)
 {
 	/* Initialize sub-system */
 	if (ipvs_start() != IPVS_SUCCESS) {
@@ -171,7 +171,7 @@ start_check(void)
 
 	/* Processing differential configuration parsing */
 	if (reload)
-		clear_diff_services();
+		clear_diff_services(old_checkers_queue);
 
 	/* Initialize IPVS topology */
 	if (!init_services())
@@ -219,6 +219,8 @@ check_signal_init(void)
 static int
 reload_check_thread(__attribute__((unused)) thread_t * thread)
 {
+	list old_checkers_queue;
+
 	/* set the reloading flag */
 	SET_RELOAD;
 
@@ -236,7 +238,6 @@ reload_check_thread(__attribute__((unused)) thread_t * thread)
 	/* Save previous checker data */
 	old_checkers_queue = checkers_queue;
 	checkers_queue = NULL;
-	ncheckers = 0;
 
 	free_ssl();
 	ipvs_stop();
@@ -246,7 +247,7 @@ reload_check_thread(__attribute__((unused)) thread_t * thread)
 	check_data = NULL;
 
 	/* Reload the conf */
-	start_check();
+	start_check(old_checkers_queue);
 
 	/* free backup data */
 	free_check_data(old_check_data);
@@ -355,7 +356,7 @@ start_check_child(void)
 	check_signal_init();
 
 	/* Start Healthcheck daemon */
-	start_check();
+	start_check(NULL);
 
 	/* Launch the scheduling I/O multiplexer */
 	launch_scheduler();
diff --git a/keepalived/check/ipwrapper.c b/keepalived/check/ipwrapper.c
index ad8c3154..34bb59f8 100644
--- a/keepalived/check/ipwrapper.c
+++ b/keepalived/check/ipwrapper.c
@@ -625,7 +625,7 @@ rs_exist(real_server_t * old_rs, list l)
 }
 
 static void
-migrate_failed_checkers(real_server_t *old_rs, real_server_t *new_rs)
+migrate_failed_checkers(real_server_t *old_rs, real_server_t *new_rs, list old_checkers_queue)
 {
 	list l;
 	element e, e1;
@@ -668,7 +668,7 @@ end:
 
 /* Clear the diff rs of the old vs */
 static void
-clear_diff_rs(virtual_server_t *old_vs, virtual_server_t *new_vs)
+clear_diff_rs(virtual_server_t *old_vs, virtual_server_t *new_vs, list old_checkers_queue)
 {
 	element e;
 	list l = old_vs->rs;
@@ -713,7 +713,7 @@ clear_diff_rs(virtual_server_t *old_vs, virtual_server_t *new_vs)
 				 * based on the failed_checkers list
 				 */
 				if (!new_vs->alpha)
-					migrate_failed_checkers(rs, new_rs);
+					migrate_failed_checkers(rs, new_rs, old_checkers_queue);
 			}
 		}
 	}
@@ -746,7 +746,7 @@ clear_diff_s_srv(virtual_server_t *old_vs, real_server_t *new_rs)
 /* When reloading configuration, remove negative diff entries
  * and copy status of existing entries to the new ones */
 void
-clear_diff_services(void)
+clear_diff_services(list old_checkers_queue)
 {
 	element e;
 	list l = old_check_data->vs;
@@ -786,7 +786,7 @@ clear_diff_services(void)
 			/* omega = false must not prevent the notifiers from being called,
 			   because the VS still exists in new configuration */
 			vs->omega = true;
-			clear_diff_rs(vs, new_vs);
+			clear_diff_rs(vs, new_vs, old_checkers_queue);
 			clear_diff_s_srv(vs, new_vs->s_svr);
 		}
 	}
diff --git a/keepalived/include/check_api.h b/keepalived/include/check_api.h
index c7bc297d..c43eca14 100644
--- a/keepalived/include/check_api.h
+++ b/keepalived/include/check_api.h
@@ -47,9 +47,7 @@ typedef struct _checker {
 } checker_t;
 
 /* Checkers queue */
-extern checker_id_t ncheckers;
 extern list checkers_queue;
-extern list old_checkers_queue;
 
 /* utility macro */
 #define CHECKER_ARG(X) ((X)->data)
diff --git a/keepalived/include/ipwrapper.h b/keepalived/include/ipwrapper.h
index 11cdbbc6..0a6c48ba 100644
--- a/keepalived/include/ipwrapper.h
+++ b/keepalived/include/ipwrapper.h
@@ -55,7 +55,7 @@ extern int svr_checker_up(checker_id_t, real_server_t *);
 extern void update_svr_checker_state(bool, checker_id_t, virtual_server_t *, real_server_t *);
 extern bool init_services(void);
 extern void clear_services(void);
-extern void clear_diff_services(void);
+extern void clear_diff_services(list);
 extern void link_vsg_to_vs(void);
 
 #endif
-- 
2.21.0