Re: [PATCH v7 02/14] usbredir: Introduce mutex for device (dis)connection

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

 



ok


Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>



On Tue, 2016-03-08 at 16:05 +0200, Dmitry Fleytman wrote:
> From: Kirill Moizik <kmoizik@xxxxxxxxxx>
> 
> This commit introduces channel mutex to allow usage of
> channel objects in mutithreaded environments.
> 
> This mutex will be used by future commits to protect
> thread unsafe usbredir functions and data structures.
> 
> Signed-off-by: Kirill Moizik <kmoizik@xxxxxxxxxx>
> Signed-off-by: Dmitry Fleytman <dfleytma@xxxxxxxxxx>
> ---
>  src/channel-usbredir-priv.h |  4 ++++
>  src/channel-usbredir.c      | 15 +++++++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/src/channel-usbredir-priv.h b/src/channel-usbredir-priv.h
> index 2c4c6f7..c987474 100644
> --- a/src/channel-usbredir-priv.h
> +++ b/src/channel-usbredir-priv.h
> @@ -51,6 +51,10 @@ void
> spice_usbredir_channel_disconnect_device(SpiceUsbredirChannel *channel);
>  
>  libusb_device *spice_usbredir_channel_get_device(SpiceUsbredirChannel
> *channel);
>  
> +void spice_usbredir_channel_lock(SpiceUsbredirChannel *channel);
> +
> +void spice_usbredir_channel_unlock(SpiceUsbredirChannel *channel);
> +
>  void spice_usbredir_channel_get_guest_filter(
>                            SpiceUsbredirChannel               *channel,
>                            const struct usbredirfilter_rule  **rules_ret,
> diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
> index c236ee7..daa35ec 100644
> --- a/src/channel-usbredir.c
> +++ b/src/channel-usbredir.c
> @@ -79,6 +79,7 @@ struct _SpiceUsbredirChannelPrivate {
>      GSimpleAsyncResult *result;
>      SpiceUsbAclHelper *acl_helper;
>  #endif
> +    STATIC_MUTEX device_connect_mutex;
>  };
>  
>  static void channel_set_handlers(SpiceChannelClass *klass);
> @@ -107,6 +108,7 @@ static void
> spice_usbredir_channel_init(SpiceUsbredirChannel *channel)
>  {
>  #ifdef USE_USBREDIR
>      channel->priv = SPICE_USBREDIR_CHANNEL_GET_PRIVATE(channel);
> +    STATIC_MUTEX_INIT(channel->priv->device_connect_mutex);
>  #endif
>  }
>  
> @@ -182,6 +184,9 @@ static void spice_usbredir_channel_finalize(GObject *obj)
>  
>      if (channel->priv->host)
>          usbredirhost_close(channel->priv->host);
> +#ifdef USE_USBREDIR
> +    STATIC_MUTEX_CLEAR(channel->priv->device_connect_mutex);
> +#endif
>  
>      /* Chain up to the parent class */
>      if (G_OBJECT_CLASS(spice_usbredir_channel_parent_class)->finalize)
> @@ -561,6 +566,16 @@ static void *usbredir_alloc_lock(void) {
>  #endif
>  }
>  
> +void spice_usbredir_channel_lock(SpiceUsbredirChannel *channel)
> +{
> +    STATIC_MUTEX_LOCK(channel->priv->device_connect_mutex);
> +}
> +
> +void spice_usbredir_channel_unlock(SpiceUsbredirChannel *channel)
> +{
> +    STATIC_MUTEX_UNLOCK(channel->priv->device_connect_mutex);
> +}
> +
>  static void usbredir_lock_lock(void *user_data) {
>      GMutex *mutex = user_data;
>  
_______________________________________________
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]