Re: [PATCH v4 12/16] usbredir: Disconnect USB device asynchronously

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

 



On Sun, Aug 16, 2015 at 03:35:49PM +0300, Dmitry Fleytman wrote:
> From: Kirill Moizik <kmoizik@xxxxxxxxxx>
> 
> Signed-off-by: Kirill Moizik <kmoizik@xxxxxxxxxx>
> Signed-off-by: Dmitry Fleytman <dfleytma@xxxxxxxxxx>
> ---
>  src/channel-usbredir.c | 43 ++++++++++++++++++++++++++++++++++++-------
>  src/map-file           |  1 +
>  2 files changed, 37 insertions(+), 7 deletions(-)
> 
> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
> index 7acfa08..9ad198b 100644
> --- a/src/channel-usbredir.c
> +++ b/src/channel-usbredir.c
> @@ -114,20 +114,49 @@ static void spice_usbredir_channel_init(SpiceUsbredirChannel *channel)
>  }
>  
>  #ifdef USE_USBREDIR
> +typedef struct _reset_cb_data
> +{
> +    gboolean migrating;
> +} reset_cb_data;
> +
> +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;
> +    g_mutex_lock(priv->flows_mutex);
> +    reset_cb_data *data = user_data;
> +
> +    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, data->migrating);
> +    g_mutex_unlock(priv->flows_mutex);
> +    g_object_unref(result);
> +    g_free(data);
> +}
> +
>  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) {
> +            reset_cb_data *data = g_new(reset_cb_data,1);
> +            data->migrating = migrating;
> +            result = g_simple_async_result_new(G_OBJECT(c),
> +                       _channel_reset_cb, data,
> +                       spice_usbredir_channel_reset);

You can use GUINT_TO_POINTER() rather than allocating a structure
wrapping a gboolean, and then GPOINTER_TO_UINT() in the callback.

Christophe

Attachment: pgp_l8Mpzxt7_.pgp
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]