summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Moore <dcm@acm.org>2009-05-27 23:15:54 -0700
committerDaniel Drake <dsd@gentoo.org>2009-05-29 11:21:11 -0400
commitcad5cb55c37137e94e35c74fdabfe42a5cbd229b (patch)
treef3b70f0260e2ef8d33bdccb60ac004253d811f49
parentb501795985a23109f176d296e7b544b4c6354528 (diff)
downloadlibusb-cad5cb55c37137e94e35c74fdabfe42a5cbd229b.tar.gz
Make synchronous transfer APIs robust against signal interruption
libusb_control_transfer and libusb_bulk_transfer are designed to be synchronous such that control is not returned until the transfer definitively succeeds or fails. That assumption is violated if a signal interrupts these functions because there is no way for the application to continue waiting for the transfer without resubmitting it. This patch changes these synchronous APIs so they do not abort in the case of a signal interruption. Signed-off-by: David Moore <dcm@acm.org>
-rw-r--r--libusb/sync.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libusb/sync.c b/libusb/sync.c
index 92e7833..72cbcf2 100644
--- a/libusb/sync.c
+++ b/libusb/sync.c
@@ -104,6 +104,8 @@ API_EXPORTED int libusb_control_transfer(libusb_device_handle *dev_handle,
while (!completed) {
r = libusb_handle_events(HANDLE_CTX(dev_handle));
if (r < 0) {
+ if (r == LIBUSB_ERROR_INTERRUPTED)
+ continue;
libusb_cancel_transfer(transfer);
while (!completed)
if (libusb_handle_events(HANDLE_CTX(dev_handle)) < 0)
@@ -172,6 +174,8 @@ static int do_sync_bulk_transfer(struct libusb_device_handle *dev_handle,
while (!completed) {
r = libusb_handle_events(HANDLE_CTX(dev_handle));
if (r < 0) {
+ if (r == LIBUSB_ERROR_INTERRUPTED)
+ continue;
libusb_cancel_transfer(transfer);
while (!completed)
if (libusb_handle_events(HANDLE_CTX(dev_handle)) < 0)