From 8ca4bac94d97769d1cbe70efe0273015b8bd2838 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Feb 24 2021 16:08:59 +0000 Subject: Fix: tools: Attempt to reestablish connections in crm_mon. If the fencing or CIB connections go away between screen refreshes, attempt to re-establish those connections. The functions that do this should be safe to be called repeatedly. See: rhbz#1880426, rhbz#1466875 patch_name: 028-crm_mon.patch present_in_specfile: true location_in_specfile: 28 squash_commits: true --- diff --git a/tools/crm_mon.c b/tools/crm_mon.c index 89d7ae2..083b7ae 100644 --- a/tools/crm_mon.c +++ b/tools/crm_mon.c @@ -126,6 +126,7 @@ static void clean_up_cib_connection(void); static void clean_up_fencing_connection(void); static crm_exit_t clean_up(crm_exit_t exit_code); static void crm_diff_update(const char *event, xmlNode * msg); +static void handle_connection_failures(int rc); static int mon_refresh_display(gpointer user_data); static int cib_connect(gboolean full); static int fencing_connect(void); @@ -690,9 +691,11 @@ reconnect_after_timeout(gpointer data) if (cib_connect(TRUE) == pcmk_ok) { /* Redraw the screen and reinstall ourselves to get called after another reconnect_msec. */ mon_refresh_display(NULL); - reconnect_timer = g_timeout_add(options.reconnect_msec, reconnect_after_timeout, NULL); + return FALSE; } - return FALSE; + + reconnect_timer = g_timeout_add(options.reconnect_msec, reconnect_after_timeout, NULL); + return TRUE; } /* Called from various places when we are disconnected from the CIB or from the @@ -887,6 +890,7 @@ static gboolean detect_user_input(GIOChannel *channel, GIOCondition condition, gpointer user_data) { int c; + int rc; gboolean config_mode = FALSE; while (1) { @@ -1001,7 +1005,14 @@ detect_user_input(GIOChannel *channel, GIOCondition condition, gpointer user_dat } refresh: - mon_refresh_display(NULL); + fencing_connect(); + rc = cib_connect(FALSE); + if (rc == pcmk_rc_ok) { + mon_refresh_display(NULL); + } else { + handle_connection_failures(rc); + } + return TRUE; } #endif