Blame SOURCES/0006-channel-usbredir-Add-FIXMEs-on-channel-reset-issues.patch

39a9e2
From 21d6d9921466eb06a8f7120da5f5592f8216fccb Mon Sep 17 00:00:00 2001
39a9e2
From: Victor Toso <me@victortoso.com>
39a9e2
Date: Wed, 5 Sep 2018 15:39:56 +0200
39a9e2
Subject: [PATCH] channel-usbredir: Add FIXMEs on channel-reset issues
39a9e2
39a9e2
This should not change code behavior, only add some comments.
39a9e2
39a9e2
This is a preparatory patch for bug below, introduced with:
39a9e2
39a9e2
    commit 9fbf679453d8dbfe797a738cb536136599d7adab
39a9e2
    Author: Kirill Moizik <kmoizik@redhat.com>
39a9e2
    Date:   Tue Mar 8 16:05:57 2016 +0200
39a9e2
39a9e2
        usbredir: Disconnect USB device asynchronously
39a9e2
39a9e2
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1625550
39a9e2
39a9e2
Signed-off-by: Victor Toso <victortoso@redhat.com>
39a9e2
Acked-by: Frediano Ziglio <fziglio@redhat.com>
39a9e2
(cherry picked from commit f1aee52b098440273f749042bde23d61b73e4da5)
39a9e2
---
39a9e2
 src/channel-usbredir.c | 27 +++++++++++++++++++--------
39a9e2
 1 file changed, 19 insertions(+), 8 deletions(-)
39a9e2
39a9e2
diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
39a9e2
index 6ffe546..13927cc 100644
39a9e2
--- a/src/channel-usbredir.c
39a9e2
+++ b/src/channel-usbredir.c
39a9e2
@@ -158,16 +158,27 @@ static void spice_usbredir_channel_reset(SpiceChannel *c, gboolean migrating)
39a9e2
     SpiceUsbredirChannel *channel = SPICE_USBREDIR_CHANNEL(c);
39a9e2
     SpiceUsbredirChannelPrivate *priv = channel->priv;
39a9e2
 
39a9e2
-    if (priv->host) {
39a9e2
-        if (priv->state == STATE_CONNECTED) {
39a9e2
-            spice_usbredir_channel_disconnect_device_async(channel, NULL,
39a9e2
-                _channel_reset_cb, GUINT_TO_POINTER(migrating));
39a9e2
-        } else {
39a9e2
-            _channel_reset_finish(channel);
39a9e2
-        }
39a9e2
-    } else {
39a9e2
+    /* Host isn't running, just reset */
39a9e2
+    if (!priv->host) {
39a9e2
         SPICE_CHANNEL_CLASS(spice_usbredir_channel_parent_class)->channel_reset(c, migrating);
39a9e2
+        return;
39a9e2
     }
39a9e2
+
39a9e2
+    /* Host is running, so we might need to disconnect the usb devices async.
39a9e2
+     * This should not block channel_reset() otherwise we might run in reconnection
39a9e2
+     * problems such as https://bugzilla.redhat.com/show_bug.cgi?id=1625550
39a9e2
+     * No operation from here on should rely on SpiceChannel as its coroutine
39a9e2
+     * might be terminated. */
39a9e2
+    
39a9e2
+    if (priv->state == STATE_CONNECTED) {
39a9e2
+        /* FIXME: We should chain-up parent's channel-reset here */
39a9e2
+        spice_usbredir_channel_disconnect_device_async(channel, NULL,
39a9e2
+            _channel_reset_cb, GUINT_TO_POINTER(migrating));
39a9e2
+        return;
39a9e2
+    }
39a9e2
+
39a9e2
+    /* FIXME: This does not chain-up with parent's channel-reset, which is a must */
39a9e2
+    _channel_reset_finish(channel);
39a9e2
 }
39a9e2
 #endif
39a9e2
 
39a9e2
-- 
39a9e2
2.20.1
39a9e2