From 1a94bcfe23ef9deca79f71769b786d774892bd3a Mon Sep 17 00:00:00 2001
From: Quentin Armitage <quentin@armitage.org.uk>
Date: Tue, 26 May 2020 15:25:11 +0100
Subject: [PATCH 093/691] Fix segfault when checker process terminates with
 SNMP

snmp_agent_close() now has to be called before thread_destroy_master()

Signed-off-by: Quentin Armitage <quentin@armitage.org.uk>
---
 keepalived/check/check_daemon.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/keepalived/check/check_daemon.c b/keepalived/check/check_daemon.c
index 7da4061..1ce274d 100644
--- a/keepalived/check/check_daemon.c
+++ b/keepalived/check/check_daemon.c
@@ -133,6 +133,11 @@ checker_terminate_phase2(void)
 	/* Remove the notify fifo */
 	notify_fifo_close(&global_data->notify_fifo, &global_data->lvs_notify_fifo);
 
+#ifdef _WITH_SNMP_CHECKER_
+	if (global_data && global_data->enable_snmp_checker)
+		check_snmp_agent_close();
+#endif
+
 	/* Destroy master thread */
 	checker_dispatcher_release();
 	thread_destroy_master(master);
@@ -141,10 +146,6 @@ checker_terminate_phase2(void)
 	free_ssl();
 
 	ipvs_stop();
-#ifdef _WITH_SNMP_CHECKER_
-	if (global_data && global_data->enable_snmp_checker)
-		check_snmp_agent_close();
-#endif
 
 	/* Stop daemon */
 	pidfile_rm(checkers_pidfile);
-- 
1.8.3.1

