summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2011-06-08 12:42:32 +0200
committerHans de Goede <hdegoede@redhat.com>2011-06-08 12:42:32 +0200
commit69b7dc82b5b5310e907628a7957e76df1f6335f3 (patch)
tree0443e04e0761d907cc19a3096d12aa963914f357
parent7cf1ee98e9b9e10d641bf76bf4334a66eb3aa7b3 (diff)
Silence cancel urb errors during iso stream cancel
When cancelling an active iso stream some iso packets will likely complete while we are cancelling, but we will see them as uncomplete as long as we've not asked libusb to check for complete transfers, this is inherently racy and there is nothing we can do. Thus we will sometimes try to cancel already completed transfers which will fail. This is not a problem, but libusb spews ugly error messages to stderr when this happens. This patch silences these error messages.
-rw-r--r--usbredirhost/usbredirhost.c11
-rw-r--r--usbredirhost/usbredirhost.h4
-rw-r--r--usbredirserver/usbredirserver.c2
3 files changed, 14 insertions, 3 deletions
diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
index 5985c9e..d348ef0 100644
--- a/usbredirhost/usbredirhost.c
+++ b/usbredirhost/usbredirhost.c
@@ -75,6 +75,7 @@ struct usbredirhost {
usbredirparser_write write_func;
void *func_priv;
int verbose;
+ libusb_context *ctx;
libusb_device *dev;
libusb_device_handle *handle;
struct libusb_config_descriptor *config;
@@ -374,7 +375,9 @@ static int usbredirhost_release(struct usbredirhost *host)
return ret;
}
-struct usbredirhost *usbredirhost_open(libusb_device_handle *usb_dev_handle,
+struct usbredirhost *usbredirhost_open(
+ libusb_context *usb_ctx,
+ libusb_device_handle *usb_dev_handle,
usbredirparser_log log_func,
usbredirparser_read read_guest_data_func,
usbredirparser_write write_guest_data_func,
@@ -392,6 +395,7 @@ struct usbredirhost *usbredirhost_open(libusb_device_handle *usb_dev_handle,
return NULL;
}
+ host->ctx = usb_ctx;
host->dev = libusb_get_device(usb_dev_handle);
host->handle = usb_dev_handle;
host->log_func = log_func;
@@ -893,6 +897,10 @@ static void usbredirhost_cancel_iso_stream(struct usbredirhost *host,
int i;
struct usbredirtransfer *transfer;
+ /* This is inherently racy, some of the transfers we consider in flight
+ may have already completed, suppress libusb cancel error messages. */
+ libusb_set_debug(host->ctx, 0);
+
for (i = 0; i < host->endpoint[EP2I(ep)].iso_transfer_count; i++) {
transfer = host->endpoint[EP2I(ep)].iso_transfer[i];
if (transfer->iso_packet_idx == ISO_SUBMITTED_IDX) {
@@ -922,6 +930,7 @@ static void usbredirhost_cancel_iso_stream(struct usbredirhost *host,
host->endpoint[EP2I(ep)].iso_pkts_per_transfer = 0;
host->endpoint[EP2I(ep)].iso_transfer_count = 0;
}
+ libusb_set_debug(host->ctx, host->verbose);
}
/**************************************************************************/
diff --git a/usbredirhost/usbredirhost.h b/usbredirhost/usbredirhost.h
index 6644311..a98072c 100644
--- a/usbredirhost/usbredirhost.h
+++ b/usbredirhost/usbredirhost.h
@@ -49,7 +49,9 @@ struct usbredirhost;
thread has its own libusb_context. IOW usbredirhost does not use
static or global variables.
*/
-struct usbredirhost *usbredirhost_open(libusb_device_handle *usb_dev_handle,
+struct usbredirhost *usbredirhost_open(
+ libusb_context *usb_ctx,
+ libusb_device_handle *usb_dev_handle,
usbredirparser_log log_func,
usbredirparser_read read_guest_data_func,
usbredirparser_write write_guest_data_func,
diff --git a/usbredirserver/usbredirserver.c b/usbredirserver/usbredirserver.c
index 67a9bf0..2733748 100644
--- a/usbredirserver/usbredirserver.c
+++ b/usbredirserver/usbredirserver.c
@@ -333,7 +333,7 @@ int main(int argc, char *argv[])
continue;
}
- host = usbredirhost_open(handle, usbredirserver_log,
+ host = usbredirhost_open(ctx, handle, usbredirserver_log,
usbredirserver_read, usbredirserver_write,
NULL, VERSION, verbose);
if (!host)