Blame SOURCES/bz1715308-make-checker-variables-non-global.patch

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