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

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