From 4f2a87f732fbbdd76562a7e221559bc6a3edfc8f Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 4 Feb 2016 11:48:01 +0200 Subject: [PATCH] MXS-22: Shutting down monitor now closes database connections Shutting down monitors is not supposed to be done ofter so there is no true benefit from keeping the connections open. With the refactoring of the monitor interface, this can be done in a centralized place. --- server/core/monitor.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/core/monitor.c b/server/core/monitor.c index f8d936ac7..60590149d 100644 --- a/server/core/monitor.c +++ b/server/core/monitor.c @@ -186,12 +186,22 @@ void monitorStartAll() void monitorStop(MONITOR *monitor) { + spinlock_acquire(&monitor->lock); if (monitor->state != MONITOR_STATE_STOPPED) { monitor->state = MONITOR_STATE_STOPPING; monitor->module->stopMonitor(monitor); monitor->state = MONITOR_STATE_STOPPED; + + MONITOR_SERVERS* db = monitor->databases; + while (db) + { + mysql_close(db->con); + db->con = NULL; + db = db->next; + } } + spinlock_release(&monitor->lock); } /**