<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 1 Mar 2016, at 24:55 AM, Jonathon Jongsma <<a href="mailto:jjongsma@redhat.com" class="">jjongsma@redhat.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On Sun, 2016-02-28 at 11:54 +0200, Dmitry Fleytman wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">From: Kirill Moizik <<a href="mailto:kmoizik@redhat.com" class="">kmoizik@redhat.com</a>><br class=""><br class="">This commit introduces channel mutex to allow usage of<br class="">channel objects in mutithreaded environments.<br class=""><br class="">This mutex will be used by future commits to protect<br class="">thread unsafe usbredir functions and data structures.<br class=""><br class="">Signed-off-by: Kirill Moizik <<a href="mailto:kmoizik@redhat.com" class="">kmoizik@redhat.com</a>><br class="">Signed-off-by: Dmitry Fleytman <<a href="mailto:dfleytma@redhat.com" class="">dfleytma@redhat.com</a>><br class="">---<br class="">src/channel-usbredir-priv.h |  4 ++++<br class="">src/channel-usbredir.c      | 19 +++++++++++++++++++<br class="">2 files changed, 23 insertions(+)<br class=""><br class="">diff --git a/src/channel-usbredir-priv.h b/src/channel-usbredir-priv.h<br class="">index 2c4c6f7..c987474 100644<br class="">--- a/src/channel-usbredir-priv.h<br class="">+++ b/src/channel-usbredir-priv.h<br class="">@@ -51,6 +51,10 @@ void<br class="">spice_usbredir_channel_disconnect_device(SpiceUsbredirChannel *channel);<br class=""><br class="">libusb_device *spice_usbredir_channel_get_device(SpiceUsbredirChannel<br class="">*channel);<br class=""><br class="">+void spice_usbredir_channel_lock(SpiceUsbredirChannel *channel);<br class="">+<br class="">+void spice_usbredir_channel_unlock(SpiceUsbredirChannel *channel);<br class="">+<br class="">void spice_usbredir_channel_get_guest_filter(<br class="">                          SpiceUsbredirChannel               *channel,<br class="">                          const struct usbredirfilter_rule  **rules_ret,<br class="">diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c<br class="">index c236ee7..c91b3f7 100644<br class="">--- a/src/channel-usbredir.c<br class="">+++ b/src/channel-usbredir.c<br class="">@@ -79,6 +79,7 @@ struct _SpiceUsbredirChannelPrivate {<br class="">    GSimpleAsyncResult *result;<br class="">    SpiceUsbAclHelper *acl_helper;<br class="">#endif<br class="">+    GMutex *device_connect_mutex;<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">As Frediano suggested in reply to an earlier version of this patch, I think</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">allocating the full structure here would be simpler.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>Yes, this is an artefact from previous versions, changed.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">};<br class=""><br class="">static void channel_set_handlers(SpiceChannelClass *klass);<br class="">@@ -107,6 +108,8 @@ static void<br class="">spice_usbredir_channel_init(SpiceUsbredirChannel *channel)<br class="">{<br class="">#ifdef USE_USBREDIR<br class="">    channel->priv = SPICE_USBREDIR_CHANNEL_GET_PRIVATE(channel);<br class="">+    channel->priv->device_connect_mutex = g_new0(GMutex, 1);<br class="">+    g_mutex_init(channel->priv->device_connect_mutex);<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">g_mutex_init() requires glib >= 2.32. configure.ac should be updated since it</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">only requires 2.28 right now.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>We did not intend to introduce code that unconditionally requires newer GLib, I used STATIC_MUTEX* defines in the next version to preserve compatibility with older GLib versions.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">#endif<br class="">}<br class=""><br class="">@@ -182,6 +185,10 @@ static void spice_usbredir_channel_finalize(GObject *obj)<br class=""><br class="">    if (channel->priv->host)<br class="">        usbredirhost_close(channel->priv->host);<br class="">+#ifdef USE_USBREDIR<br class="">+    g_mutex_clear(channel->priv->device_connect_mutex);<br class="">+    g_free(channel->priv->device_connect_mutex);<br class="">+#endif<br class=""><br class="">    /* Chain up to the parent class */<br class="">    if (G_OBJECT_CLASS(spice_usbredir_channel_parent_class)->finalize)<br class="">@@ -561,6 +568,18 @@ static void *usbredir_alloc_lock(void) {<br class="">#endif<br class="">}<br class=""><br class="">+void spice_usbredir_channel_lock(SpiceUsbredirChannel *channel)<br class="">+{<br class="">+    g_return_if_fail(SPICE_IS_USBREDIR_CHANNEL(channel));<br class="">+    g_mutex_lock(channel->priv->device_connect_mutex);<br class="">+}<br class="">+<br class="">+void spice_usbredir_channel_unlock(SpiceUsbredirChannel *channel)<br class="">+{<br class="">+    g_return_if_fail(SPICE_IS_USBREDIR_CHANNEL(channel));<br class="">+    g_mutex_unlock(channel->priv->device_connect_mutex);<br class="">+}<br class="">+<br class="">static void usbredir_lock_lock(void *user_data) {<br class="">    GMutex *mutex = user_data;</blockquote></div></blockquote></div><br class=""></body></html>