summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJonathon Jongsma <jjongsma@redhat.com>2016-03-10 10:54:11 -0600
committerJonathon Jongsma <jjongsma@redhat.com>2016-03-11 09:52:46 -0600
commit3e5004dd5758da27b6f7dab3808769303c30044e (patch)
tree5317ace3a479e092c639fb3df8d4d13462bed78b /src
parentcc8adb63ee5b9a554b9e237f825741cf4fcc2c09 (diff)
Introduce spice_usb_acl_helper_cancel()
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.
Diffstat (limited to 'src')
-rw-r--r--src/channel-usbredir.c2
-rw-r--r--src/usb-acl-helper.c13
-rw-r--r--src/usb-acl-helper.h1
3 files changed, 15 insertions, 1 deletions
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