summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2012-03-06 11:34:58 +0100
committerHans de Goede <hdegoede@redhat.com>2012-03-06 11:37:05 +0100
commit192fb1989edeff552f79b2365e8aa3c00d0835e2 (patch)
treec73c1a183c96c28c73224633f09ead65a2471edc
parent4d9242ded6e0d89e17399979e0c42608252abdcb (diff)
usbredirhost: Failure to re-claim after a set_config means we've lost the dev
So cleanup on failure to re-claim after a set_config, and let our user know that we've lost the device with a new usbredirhost_read_device_lost status. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--usbredirhost/usbredirhost.c9
-rw-r--r--usbredirhost/usbredirhost.h6
2 files changed, 12 insertions, 3 deletions
diff --git a/usbredirhost/usbredirhost.c b/usbredirhost/usbredirhost.c
index 9a601dc..5455593 100644
--- a/usbredirhost/usbredirhost.c
+++ b/usbredirhost/usbredirhost.c
@@ -1446,8 +1446,13 @@ static void usbredirhost_set_configuration(void *priv, uint32_t id,
host->active_config = set_config->configuration;
status.status = usbredirhost_claim(host);
- if (status.status == usb_redir_success)
- usbredirhost_send_interface_n_ep_info(host);
+ if (status.status != usb_redir_success) {
+ usbredirhost_clear_device(host);
+ host->read_status = usbredirhost_read_device_lost;
+ goto exit;
+ }
+
+ usbredirhost_send_interface_n_ep_info(host);
exit:
status.configuration = host->active_config;
diff --git a/usbredirhost/usbredirhost.h b/usbredirhost/usbredirhost.h
index 3895a6c..052416a 100644
--- a/usbredirhost/usbredirhost.h
+++ b/usbredirhost/usbredirhost.h
@@ -116,12 +116,16 @@ int usbredirhost_set_device(struct usbredirhost *host,
On an usbredirhost_read_io_error this function will continue where it
left of the last time on the next call. On an usbredirhost_read_parse_error
it will skip to the next packet (*). On an usbredirhost_read_device_rejected
- error, you are expected to call usbredirhost_close().
+ error, you are expected to call usbredirhost_set_device(host, NULL).
+ An usbredirhost_read_device_lost error means that the host has done the
+ equivalent of usbredirhost_set_device(host, NULL) itself because the
+ connection to the device was lost.
*) As determined by the faulty's package headers length field */
enum {
usbredirhost_read_io_error = -1,
usbredirhost_read_parse_error = -2,
usbredirhost_read_device_rejected = -3,
+ usbredirhost_read_device_lost = -4,
};
int usbredirhost_read_guest_data(struct usbredirhost *host);