File pacemaker-crm_resource-prevent-disconnection-from-crmd-during-cleanup.patch of Package pacemaker.openSUSE_Leap_42.3_Update

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-1.1.16+20170320.77ea74d/tools/crm_resource.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/tools/crm_resource.c
+++ pacemaker-1.1.16+20170320.77ea74d/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-1.1.16+20170320.77ea74d/tools/crm_resource_runtime.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/tools/crm_resource_runtime.c
+++ pacemaker-1.1.16+20170320.77ea74d/tools/crm_resource_runtime.c
@@ -668,10 +668,18 @@ cli_resource_delete(crm_ipc_t *crmd_chan
                rsc->id, host_uname, pcmk_strerror(rc));
         return rc;
     }
+
     if (node->details->remote_rsc == NULL) {
         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;
+
     rsc_name = rsc_fail_name(rsc);
     if (is_remote_node(node)) {
         attr_options |= attrd_opt_remote;
openSUSE Build Service is sponsored by