[Spice-devel] [PATCH v5 09/13] usbredir: Disconnect USB device asynchronously
Dmitry Fleytman
dmitry at daynix.com
Sun Feb 28 08:59:15 UTC 2016
> On 11 Feb 2016, at 24:41 AM, Jonathon Jongsma <jjongsma at redhat.com> wrote:
>
> On Thu, 2015-10-29 at 17:27 +0200, Dmitry Fleytman wrote:
>> From: Kirill Moizik <kmoizik at redhat.com>
>>
>> Signed-off-by: Kirill Moizik <kmoizik at redhat.com>
>> Signed-off-by: Dmitry Fleytman <dfleytma at redhat.com>
>> ---
>> src/channel-usbredir.c | 36 +++++++++++++++++++++++++++++-------
>> src/map-file | 1 +
>> 2 files changed, 30 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
>> index 8519957..ed4a937 100644
>> --- a/src/channel-usbredir.c
>> +++ b/src/channel-usbredir.c
>> @@ -114,20 +114,42 @@ static void
>> spice_usbredir_channel_init(SpiceUsbredirChannel *channel)
>> }
>>
>> #ifdef USE_USBREDIR
>> +
>> +static void _channel_reset_cb(GObject *gobject,
>> + GAsyncResult *result,
>> + gpointer user_data)
>> +{
>> + SpiceChannel *spice_channel = SPICE_CHANNEL(gobject);
>> + SpiceUsbredirChannel *channel = SPICE_USBREDIR_CHANNEL(spice_channel);
>> + SpiceUsbredirChannelPrivate *priv = channel->priv;
>> + gboolean migrating = GPOINTER_TO_UINT(user_data);
>> + g_mutex_lock(priv->flows_mutex);
>> +
>> + usbredirhost_close(priv->host);
>> + priv->host = NULL;
>> + /* Call set_context to re-create the host */
>> + spice_usbredir_channel_set_context(channel, priv->context);
>> + SPICE_CHANNEL_CLASS(spice_usbredir_channel_parent_class)
>> ->channel_reset(spice_channel, migrating);
>> + g_mutex_unlock(priv->flows_mutex);
>> + g_object_unref(result);
>> +}
>> +
>> static void spice_usbredir_channel_reset(SpiceChannel *c, gboolean migrating)
>> {
>> SpiceUsbredirChannel *channel = SPICE_USBREDIR_CHANNEL(c);
>> SpiceUsbredirChannelPrivate *priv = channel->priv;
>>
>> + GSimpleAsyncResult *result;
>> if (priv->host) {
>> - if (priv->state == STATE_CONNECTED)
>> - spice_usbredir_channel_disconnect_device(channel);
>> - usbredirhost_close(priv->host);
>> - priv->host = NULL;
>> - /* Call set_context to re-create the host */
>> - spice_usbredir_channel_set_context(channel, priv->context);
>> + if (priv->state == STATE_CONNECTED) {
>> + result = g_simple_async_result_new(G_OBJECT(c),
>> + _channel_reset_cb, GUINT_TO_POINTER(migrating),
>> + spice_usbredir_channel_reset);
>> + spice_usbredir_channel_disconnect_device_async(channel, result,
>> NULL);
>> + }
>> + } else {
>> + SPICE_CHANNEL_CLASS(spice_usbredir_channel_parent_class)
>> ->channel_reset(c, migrating);
>
> This section will need to be refactored a bit if we change the signature of
> _disconnect_device_async() as I suggested on the earlier patch.
Done.
>
>> }
>> - SPICE_CHANNEL_CLASS(spice_usbredir_channel_parent_class)
>> ->channel_reset(c, migrating);
>> }
>> #endif
>>
>> diff --git a/src/map-file b/src/map-file
>> index 92a9883..1f7755b 100644
>> --- a/src/map-file
>> +++ b/src/map-file
>> @@ -127,6 +127,7 @@ spice_usb_device_manager_can_redirect_device;
>> spice_usb_device_manager_connect_device_async;
>> spice_usb_device_manager_connect_device_finish;
>> spice_usb_device_manager_disconnect_device;
>> +spice_usb_device_manager_disconnect_device_async;
>
> This should be moved to the patch which introduces this function.
Moved. Thanks.
>
>> spice_usb_device_manager_get;
>> spice_usb_device_manager_get_devices;
>> spice_usb_device_manager_get_devices_with_filter;
>
>
> Reviewed-by: Jonathon Jongsma <jjongsma at redhat.com <mailto:jjongsma at redhat.com>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20160228/f3670c1a/attachment-0001.html>
More information about the Spice-devel
mailing list