summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-09-17 12:05:09 +0200
committerHans de Goede <hdegoede@redhat.com>2012-09-26 12:06:15 +0200
commit46056c8b86b722462800a91b6c472374bc6c3810 (patch)
tree40adb1fc5462e208c6625672d49c7a9a5e1aa7e7
parent7cbd9d3509113b6d2d411a49ab7145351d79c354 (diff)
Make usbredir*_has_data_to_write return the write queue depth
Instead of only returning 0 or 1, this can be used for flowcontrol purposes. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Conflicts: ChangeLog usbredirparser/usbredirparser.c
-rw-r--r--ChangeLog10
-rw-r--r--TODO1
-rw-r--r--usbredirhost/usbredirhost.h4
-rw-r--r--usbredirparser/usbredirparser.c7
-rw-r--r--usbredirparser/usbredirparser.h4
5 files changed, 19 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index d79e1f0..6861b8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+usbredir-0.4.4 26 September 2012
+--------------------------------
+-usbredirparser:
+ -usbredirparser_has_data_to_write now returns the write queue depth, instead
+ of only 0 or 1
+-usbredirhost:
+ -Remove bulk packets time out, this fixes various devices not working
+ -usbredirhost_has_data_to_write now returns the write queue depth, instead
+ of only 0 or 1
+
usbredir-0.4.3 2 April 2012
---------------------------
-usbredirhost:
diff --git a/TODO b/TODO
index 2085006..e6715b1 100644
--- a/TODO
+++ b/TODO
@@ -4,4 +4,3 @@
* cancel pending packets / active streams before reset?
* add a queue_buf call to parser, use it in host to avoid memcpy of
"in" bulk transfers
-* use libusb strerror equivalent instead of numeric error codes in logs
diff --git a/usbredirhost/usbredirhost.h b/usbredirhost/usbredirhost.h
index 052416a..77fb8a2 100644
--- a/usbredirhost/usbredirhost.h
+++ b/usbredirhost/usbredirhost.h
@@ -129,10 +129,10 @@ enum {
};
int usbredirhost_read_guest_data(struct usbredirhost *host);
-/* If this returns true there is data queued to write to the usb-guest */
+/* This returns the number of usbredir packets queued up for writing */
int usbredirhost_has_data_to_write(struct usbredirhost *host);
-/* Call this when usbredirhost_has_data_to_write returns true
+/* Call this when usbredirhost_has_data_to_write returns > 0
returns 0 on success, -1 if a write error happened.
If a write error happened, this function will retry writing any queued data
on the next call, and will continue doing so until it has succeeded! */
diff --git a/usbredirparser/usbredirparser.c b/usbredirparser/usbredirparser.c
index 5b4c1ce..d2c3ef2 100644
--- a/usbredirparser/usbredirparser.c
+++ b/usbredirparser/usbredirparser.c
@@ -69,6 +69,7 @@ struct usbredirparser_priv {
int data_read;
int to_skip;
struct usbredirparser_buf *write_buf;
+ int write_buf_count;
};
static void va_log(struct usbredirparser_priv *parser, int verbose,
@@ -792,7 +793,7 @@ int usbredirparser_has_data_to_write(struct usbredirparser *parser_pub)
{
struct usbredirparser_priv *parser =
(struct usbredirparser_priv *)parser_pub;
- return parser->write_buf != NULL;
+ return parser->write_buf_count;
}
int usbredirparser_do_write(struct usbredirparser *parser_pub)
@@ -827,6 +828,7 @@ int usbredirparser_do_write(struct usbredirparser *parser_pub)
if (!(parser->flags & usbredirparser_fl_write_cb_owns_buffer))
free(wbuf->buf);
free(wbuf);
+ parser->write_buf_count--;
}
}
UNLOCK(parser);
@@ -893,13 +895,14 @@ static void usbredirparser_queue(struct usbredirparser *parser_pub,
if (!parser->write_buf) {
parser->write_buf = new_wbuf;
} else {
- /* maybe we should limit the write_buf stack depth ? */
+ /* limiting the write_buf's stack depth is our users responsibility */
wbuf = parser->write_buf;
while (wbuf->next)
wbuf = wbuf->next;
wbuf->next = new_wbuf;
}
+ parser->write_buf_count++;
UNLOCK(parser);
}
diff --git a/usbredirparser/usbredirparser.h b/usbredirparser/usbredirparser.h
index 2b5fd1d..ff8f5da 100644
--- a/usbredirparser/usbredirparser.h
+++ b/usbredirparser/usbredirparser.h
@@ -221,10 +221,10 @@ enum {
};
int usbredirparser_do_read(struct usbredirparser *parser);
-/* If this returns true the parser has data queued to write to its peer */
+/* This returns the number of usbredir packets queued up for writing */
int usbredirparser_has_data_to_write(struct usbredirparser *parser);
-/* Call this when usbredirparser_has_data_to_write returns true
+/* Call this when usbredirparser_has_data_to_write returns > 0
returns 0 on success, -1 if a write error happened.
If a write error happened, this function will retry writing any queued data
on the next call, and will continue doing so until it has succeeded! */