Blame SOURCES/0005-proxy-Check-if-operation-is-cancelled-before-disconn.patch

546e1e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
546e1e
From: "Eduardo Lima (Etrunko)" <etrunko@redhat.com>
546e1e
Date: Thu, 2 Feb 2017 15:13:48 -0200
546e1e
Subject: [PATCH] proxy: Check if operation is cancelled before disconnecting
546e1e
 signal
546e1e
546e1e
According to the documentation, g_cancellable_disconnect() waits for the
546e1e
signal handler to finish, and if it is called from the handler itself, it
546e1e
will result in a deadlock. To avoid it, we check if the operation is
546e1e
cancelled and if so, call g_signal_handler_disconnect() instead of
546e1e
g_cancellable_disconnect().
546e1e
546e1e
https://developer.gnome.org/gio/stable/GCancellable.html#g-cancellable-disconnect
546e1e
546e1e
Signed-off-by: Eduardo Lima (Etrunko) <etrunko@redhat.com>
546e1e
---
546e1e
 govirt/ovirt-proxy.c | 10 +++++++++-
546e1e
 1 file changed, 9 insertions(+), 1 deletion(-)
546e1e
546e1e
diff --git a/govirt/ovirt-proxy.c b/govirt/ovirt-proxy.c
546e1e
index 2b690b6..921e22e 100644
546e1e
--- a/govirt/ovirt-proxy.c
546e1e
+++ b/govirt/ovirt-proxy.c
546e1e
@@ -218,7 +218,15 @@ static void ovirt_proxy_call_async_data_free(OvirtProxyCallAsyncData *data)
546e1e
             g_object_unref(G_OBJECT(data->result));
546e1e
         }
546e1e
         if ((data->cancellable != NULL) && (data->cancellable_cb_id != 0)) {
546e1e
-            g_cancellable_disconnect(data->cancellable, data->cancellable_cb_id);
546e1e
+            if (g_cancellable_is_cancelled(data->cancellable)) {
546e1e
+                /* Cancellable has already been cancelled, we don't need to use
546e1e
+                 * g_cancellable_disconnect() to disconnect the signal handler
546e1e
+                 * as we know the 'cancelled' signal is no longer going to be emitted
546e1e
+                 */
546e1e
+                g_signal_handler_disconnect(data->cancellable, data->cancellable_cb_id);
546e1e
+            } else {
546e1e
+                g_cancellable_disconnect(data->cancellable, data->cancellable_cb_id);
546e1e
+            }
546e1e
         }
546e1e
         g_clear_object(&data->cancellable);
546e1e
         g_slice_free(OvirtProxyCallAsyncData, data);