[PATCH spice-gtk v2 1/6] Introduce spice_usb_acl_helper_cancel()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function explicitly cancels a open_acl() task. It is similar to
close_acl(), but its behavior is more explicit. This function is very
similar to the existing close_acl() function but it requires that the
task has not already been completed. Also, although it releases its
reference on priv->result to avoid circular references, it doesn't call
cleanup(), preferring instead to wait for the destructor to clean up.
This makes the close_acl() function essentially pointless and will be
removed in the following commit.
---
 src/channel-usbredir.c |  2 +-
 src/usb-acl-helper.c   | 13 +++++++++++++
 src/usb-acl-helper.h   |  1 +
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index f16a30f..38d5aaf 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -419,7 +419,7 @@ void spice_usbredir_channel_disconnect_device(SpiceUsbredirChannel *channel)
     case STATE_WAITING_FOR_ACL_HELPER:
         priv->state = STATE_DISCONNECTING;
         /* We're still waiting for the acl helper -> cancel it */
-        spice_usb_acl_helper_close_acl(priv->acl_helper);
+        spice_usb_acl_helper_cancel(priv->acl_helper);
         break;
 #endif
     case STATE_CONNECTED:
diff --git a/src/usb-acl-helper.c b/src/usb-acl-helper.c
index 6a49627..4ed57b9 100644
--- a/src/usb-acl-helper.c
+++ b/src/usb-acl-helper.c
@@ -297,3 +297,16 @@ void spice_usb_acl_helper_close_acl(SpiceUsbAclHelper *self)
 
     spice_usb_acl_helper_cleanup(self);
 }
+
+G_GNUC_INTERNAL
+void spice_usb_acl_helper_cancel(SpiceUsbAclHelper *self)
+{
+    g_return_if_fail(SPICE_IS_USB_ACL_HELPER(self));
+
+    SpiceUsbAclHelperPrivate *priv = self->priv;
+    g_return_if_fail(priv->result != NULL);
+
+    async_result_set_cancelled(priv->result);
+    g_simple_async_result_complete_in_idle(priv->result);
+    g_clear_object(&priv->result);
+}
diff --git a/src/usb-acl-helper.h b/src/usb-acl-helper.h
index 2d41b68..d9a9def 100644
--- a/src/usb-acl-helper.h
+++ b/src/usb-acl-helper.h
@@ -66,6 +66,7 @@ gboolean spice_usb_acl_helper_open_acl_finish(
     SpiceUsbAclHelper *self, GAsyncResult *res, GError **err);
 
 void spice_usb_acl_helper_close_acl(SpiceUsbAclHelper *self);
+void spice_usb_acl_helper_cancel(SpiceUsbAclHelper *self);
 
 G_END_DECLS
 
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]