From f8f980340256ab5bef5385cd3bc082fdfb7613ed Mon Sep 17 00:00:00 2001 From: "Gao,Yan" Date: Thu, 7 Mar 2019 15:01:26 +0100 Subject: [PATCH] Fix: sbd-cluster: finalize cmap connection if disconnected from cluster Previously if sbd cluster servant anyhow got dis-/reconnected from the cluster, it'd start hogging CPU keeping polling the main loop source from the old cmap connection. --- src/sbd-cluster.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/sbd-cluster.c b/src/sbd-cluster.c index 51bb456..541212f 100644 --- a/src/sbd-cluster.c +++ b/src/sbd-cluster.c @@ -174,6 +174,25 @@ cmap_dispatch_callback (gpointer user_data) return TRUE; } +static void +cmap_destroy(void) +{ + if (cmap_source) { + g_source_destroy(cmap_source); + cmap_source = NULL; + } + + if (track_handle) { + cmap_track_delete(cmap_handle, track_handle); + track_handle = 0; + } + + if (cmap_handle) { + cmap_finalize(cmap_handle); + cmap_handle = 0; + } +} + static gboolean sbd_get_two_node(void) { @@ -217,18 +236,7 @@ sbd_get_two_node(void) return TRUE; out: - if (cmap_source) { - g_source_destroy(cmap_source); - cmap_source = NULL; - } - if (track_handle) { - cmap_track_delete(cmap_handle, track_handle); - track_handle = 0; - } - if (cmap_handle) { - cmap_finalize(cmap_handle); - cmap_handle = 0; - } + cmap_destroy(); return FALSE; } @@ -327,6 +335,12 @@ sbd_membership_destroy(gpointer user_data) { cl_log(LOG_WARNING, "Lost connection to %s", name_for_cluster_type(get_cluster_type())); + if (get_cluster_type() != pcmk_cluster_unknown) { +#if SUPPORT_COROSYNC && CHECK_TWO_NODE + cmap_destroy(); +#endif + } + set_servant_health(pcmk_health_unclean, LOG_ERR, "Cluster connection terminated"); notify_parent(); -- 1.8.3.1