[Spice-commits] src/channel-usbredir.c

Victor Toso de Carvalho victortoso at kemper.freedesktop.org
Wed Jul 26 13:15:43 UTC 2017


 src/channel-usbredir.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 3fb475a9c9eac077c9eebb3623fe14b4cd1e965a
Author: leaboy <wlbleaboy at 126.com>
Date:   Mon Jun 12 17:44:45 2017 +0800

    usbredir: fix deadlock on error
    
    The current code deadlocks when a USB error occurs, releasing the
    channel lock before the idle is called fixes this problem.
    
    More specifically when an error occurs, we queue a call to device_error
    in an idle, and switch to the main context. The device_error() calls
    spice_usbredir_channel_disconnect_device() which needs the channel to be
    unlocked as it calls spice_usbredir_channel_lock().
    
    Examples:
    - Redirect USB Storage device to the guest and copy some big file. While
      copy is ongoing, unplug the USB Storage from the client machine;
    - Unplug the usb device from the client machine while the USB Storage
      device is being identified in the guest.
    - With the auto-redirection option enabled, plug and unplug the USB
      Storage Device frequently.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1353528
    Signed-off-by: Victor Toso <victortoso at redhat.com>
    Acked-by: Pavel Grunt <pgrunt at redhat.com>

diff --git a/src/channel-usbredir.c b/src/channel-usbredir.c
index fef62ce..1f791bc 100644
--- a/src/channel-usbredir.c
+++ b/src/channel-usbredir.c
@@ -927,15 +927,16 @@ static void usbredir_handle_msg(SpiceChannel *c, SpiceMsgIn *in)
         err_data.caller = coroutine_self();
         err_data.spice_device = g_boxed_copy(spice_usb_device_get_type(), spice_device);
         err_data.error = err;
+        spice_usbredir_channel_unlock(channel);
         g_idle_add(device_error, &err_data);
         coroutine_yield(NULL);
 
         g_boxed_free(spice_usb_device_get_type(), err_data.spice_device);
 
         g_error_free(err);
+    } else {
+        spice_usbredir_channel_unlock(channel);
     }
-
-    spice_usbredir_channel_unlock(channel);
 }
 
 #endif /* USE_USBREDIR */


More information about the Spice-commits mailing list