summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-10-18 20:51:23 +0200
committerHans de Goede <hdegoede@redhat.com>2013-11-19 10:34:53 +0100
commiteba5a900bbf65d98e8840deb3dd8c0a166e9fc55 (patch)
tree59e10784287100033e1da649f515985faa610c77
parentc5273022a1c87778408ae60cd5bba62f9b6e2a32 (diff)
usbredirhost: Ensure all in flight urbs are cancelled before a reset
The guest should have cancelled any pending urbs already, but the cancellations have not necessary completed when we receive a reset. If we then continue with the reset pending urbs may complete with an error code of LIBUSB_TRANSFER_NO_DEVICE, causing us to see a device disconnect. We also need to cleanly shutdown any streams and let the guest know they should be restarted after the reset. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--usbredirhost/usbredirhost.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
index 6d361d2..5ec3664 100644
--- a/usbredirhost/usbredirhost.c
+++ b/usbredirhost/usbredirhost.c
@@ -1548,6 +1548,17 @@ static void usbredirhost_reset(void *priv)
return;
}
+ /*
+ * The guest should have cancelled any pending urbs already, but the
+ * cancellations may be awaiting completion, and if we then do a reset
+ * they will complete with an error code of LIBUSB_TRANSFER_NO_DEVICE.
+ *
+ * And we also need to cleanly shutdown any streams (and let the guest
+ * know they should be restarted after the reset).
+ */
+ if (usbredirhost_cancel_pending_urbs(host, 1))
+ usbredirhost_wait_for_cancel_completion(host);
+
r = usbredirhost_reset_device(host);
if (r != 0) {
host->read_status = usbredirhost_read_device_lost;