File pacemaker-crm_resource-prevent-disconnection-from-crmd-during-cleanup.patch of Package pacemaker.14737

commit a79650a89502e35c085870f631b66ddef6e8dd71
Author: Andrew Beekhof <andrew@beekhof.net>
Date:   Thu Oct 19 14:01:18 2017 +1100

    Fix: crm_resource: Prevent disconnection from crmd during cleanup

Index: pacemaker/tools/crm_resource.c
===================================================================
--- pacemaker.orig/tools/crm_resource.c
+++ pacemaker/tools/crm_resource.c
@@ -57,6 +57,7 @@ resource_ipc_connection_destroy(gpointer
     crm_exit(1);
 }
 
+static bool mainloop_running = FALSE;
 static void
 start_mainloop(void)
 {
@@ -64,6 +65,7 @@ start_mainloop(void)
         return;
     }
 
+    mainloop_running = TRUE;
     mainloop = g_main_new(FALSE);
     fprintf(stderr, "Waiting for %d replies from the CRMd", crmd_replies_needed);
     crm_debug("Waiting for %d replies from the CRMd", crmd_replies_needed);
@@ -81,7 +83,7 @@ resource_ipc_callback(const char *buffer
     crm_log_xml_trace(msg, "[inbound]");
 
     crmd_replies_needed--;
-    if (crmd_replies_needed == 0) {
+    if (crmd_replies_needed == 0 && mainloop_running) {
         fprintf(stderr, " OK\n");
         crm_debug("Got all the replies we expected");
         return crm_exit(pcmk_ok);
Index: pacemaker/tools/crm_resource_runtime.c
===================================================================
--- pacemaker.orig/tools/crm_resource_runtime.c
+++ pacemaker/tools/crm_resource_runtime.c
@@ -661,6 +661,13 @@ cli_resource_delete(cib_t *cib_conn, crm
             crmd_replies_needed++;
         }
 
+        crm_trace("Processing %d mainloop inputs", crmd_replies_needed);
+        while(g_main_context_iteration(NULL, FALSE)) {
+            crm_trace("Processed mainloop input, %d still remaining",
+                          crmd_replies_needed);
+        }
+        crmd_replies_needed = 0;
+
         if(is_not_set(rsc->flags, pe_rsc_unique)) {
             char *id = clone_strip(rsc->id);
             attr_name = crm_strdup_printf("fail-count-%s", id);
openSUSE Build Service is sponsored by