summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-09-18 08:47:28 +0200
committerHans de Goede <hdegoede@redhat.com>2012-09-26 12:06:50 +0200
commit61040be4772ed5c3d6b5ea39c138a8c4a97ae8d0 (patch)
treecc34d81c5a0bb67aeea9ae150cb2d65553b08420
parent46056c8b86b722462800a91b6c472374bc6c3810 (diff)
usbredirhost: Drop isoc in packets when write queue gets too large
If the write queue gets too large our network connection likely is not keeping up. The best (and only) thing we can do then is drop isoc input packages, these are also the likely cause of this, since all other transfer types more or less auto-adjust to the network speed (rhbz#855737). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--usbredirhost/usbredirhost.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
index 8330df5..76554e3 100644
--- a/usbredirhost/usbredirhost.c
+++ b/usbredirhost/usbredirhost.c
@@ -83,6 +83,7 @@ struct usbredirhost_ep {
uint8_t type;
uint8_t interval;
uint8_t interface;
+ uint8_t warn_on_drop;
uint8_t iso_started;
uint8_t iso_pkts_per_transfer;
uint8_t iso_transfer_count;
@@ -403,6 +404,7 @@ static void usbredirhost_parse_interface(struct usbredirhost *host, int i)
intf_desc->endpoint[j].bInterval;
host->endpoint[EP2I(ep_address)].interface =
intf_desc->bInterfaceNumber;
+ host->endpoint[EP2I(ep_address)].warn_on_drop = 1;
}
}
@@ -1098,11 +1100,23 @@ static void usbredirhost_iso_packet_complete(
.status = status,
.length = len
};
- DEBUG("iso-out ep %02X status %d len %d", ep, status, len);
- usbredirparser_send_iso_packet(host->parser, transfer->id,
+ /* USB-2 is max 8000 packets / sec, if we've queued up more
+ then 0.1 sec, assume our connection is not keeping up and
+ start dropping packets. */
+ if (usbredirparser_has_data_to_write(host->parser) < 800) {
+ DEBUG("iso-out ep %02X status %d len %d", ep, status, len);
+ usbredirparser_send_iso_packet(host->parser, transfer->id,
&iso_packet,
libusb_get_iso_packet_buffer(libusb_transfer, i),
len);
+ } else {
+ if (host->endpoint[EP2I(ep)].warn_on_drop) {
+ WARNING("iso stream on endpoint %02X, connection too slow, dropping packets", ep);
+ host->endpoint[EP2I(ep)].warn_on_drop = 0;
+ }
+ DEBUG("iso-out ep %02X dropping packet status %d len %d",
+ ep, status, len);
+ }
transfer->id++;
} else {
DEBUG("iso-in complete ep %02X pkt %d len %d id %d",