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