From d79e2dcfc84d937db3c6eb3d17520aaf6e7bba4c Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Mon, 13 Jan 2020 21:13:32 +1100 Subject: ctdb-daemon: Only stop monitoring if it has been initialised This avoids a crash if ctdb_shutdown_sequence() is called before monitoring is initialised. Switch to using TALLOC_FREE() while touching this function. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/server/ctdb_monitor.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ctdb') diff --git a/ctdb/server/ctdb_monitor.c b/ctdb/server/ctdb_monitor.c index cfa3a6a1bfa..5c694bde969 100644 --- a/ctdb/server/ctdb_monitor.c +++ b/ctdb/server/ctdb_monitor.c @@ -416,8 +416,12 @@ static void ctdb_check_health(struct tevent_context *ev, */ void ctdb_stop_monitoring(struct ctdb_context *ctdb) { - talloc_free(ctdb->monitor->monitor_context); - ctdb->monitor->monitor_context = NULL; + if (ctdb->monitor == NULL) { + D_NOTICE("Monitoring not yet initialised\n"); + return; + } + + TALLOC_FREE(ctdb->monitor->monitor_context); ctdb->monitor->next_interval = 5; DEBUG(DEBUG_NOTICE,("Monitoring has been stopped\n")); -- cgit v1.2.1