diff options
author | Nathan Hjelm <hjelmn@me.com> | 2013-07-23 20:56:37 -0600 |
---|---|---|
committer | hjelmn <Nathan Hjelm hjelmn@cs.unm.edu> | 2013-07-30 09:08:39 -0600 |
commit | 707d500b9fea002f075cf30458a602f28dbd1348 (patch) | |
tree | 8cd9ad3ad15d2dd9ca610347c08f4115f3deedc3 /libusb/io.c | |
parent | 97958ba756b2f90aa9f65cc7674bc558768dde9f (diff) | |
download | android_external_libusbx-707d500b9fea002f075cf30458a602f28dbd1348.tar.gz android_external_libusbx-707d500b9fea002f075cf30458a602f28dbd1348.tar.bz2 android_external_libusbx-707d500b9fea002f075cf30458a602f28dbd1348.zip |
keep a reference to the device for each active transfer and let the backend handle cancelling active transfers when a device is disconnected
This commit should fix issues with active transfers when a device is
disconnected. The backend is responsible for making sure the completion
callbacks are made, not the hotplug code. This should fix a number of
issues including duplicate callbacks and segmentation faults.
References #124.
Diffstat (limited to 'libusb/io.c')
-rw-r--r-- | libusb/io.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libusb/io.c b/libusb/io.c index 4368b99..8438e77 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -1459,6 +1459,8 @@ int API_EXPORTED libusb_submit_transfer(struct libusb_transfer *transfer) } usbi_mutex_unlock(&ctx->flying_transfers_lock); + /* keep a reference to this device */ + libusb_ref_device(transfer->dev_handle->dev); out: updated_fds = (itransfer->flags & USBI_TRANSFER_UPDATED_FDS); usbi_mutex_unlock(&itransfer->lock); @@ -1562,6 +1564,7 @@ int usbi_handle_transfer_completion(struct usbi_transfer *itransfer, usbi_mutex_lock(&ctx->event_waiters_lock); usbi_cond_broadcast(&ctx->event_waiters_cond); usbi_mutex_unlock(&ctx->event_waiters_lock); + libusb_unref_device(transfer->dev_handle->dev); return 0; } |