summaryrefslogtreecommitdiff
path: root/libgphoto2_port/libusb1
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2015-11-15 13:56:39 +0100
committerMarcus Meissner <marcus@jet.franken.de>2015-11-15 13:56:39 +0100
commita8c6c774f1428a1e6bde7d98d3891107642002c5 (patch)
treee96aa5709742583b3dc307b4d95e7b2e810d8a59 /libgphoto2_port/libusb1
parent14f9c6256e9c56eaf12749a38c2b7877ace27c19 (diff)
downloadlibgphoto2-a8c6c774f1428a1e6bde7d98d3891107642002c5.tar.gz
free the async interrupts before resetting device, so they do not
trigger
Diffstat (limited to 'libgphoto2_port/libusb1')
-rw-r--r--libgphoto2_port/libusb1/libusb1.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/libgphoto2_port/libusb1/libusb1.c b/libgphoto2_port/libusb1/libusb1.c
index 35ab545db..5edfba8dd 100644
--- a/libgphoto2_port/libusb1/libusb1.c
+++ b/libgphoto2_port/libusb1/libusb1.c
@@ -432,7 +432,7 @@ gp_libusb1_open (GPPort *port)
}
static int
-gp_libusb1_close (GPPort *port)
+_close_async_interrupts(GPPort *port)
{
int i, haveone;
struct timeval tv;
@@ -467,7 +467,21 @@ gp_libusb1_close (GPPort *port)
}
if (haveone)
LOG_ON_LIBUSB_E (libusb_handle_events(port->pl->ctx));
+ return GP_OK;
+}
+static int
+gp_libusb1_close (GPPort *port)
+{
+ int i, haveone;
+ struct timeval tv;
+
+ C_PARAMS (port);
+
+ if (port->pl->dh == NULL)
+ return GP_OK;
+
+ _close_async_interrupts(port);
if (libusb_release_interface (port->pl->dh,
port->settings.usb.interface) < 0) {
@@ -566,6 +580,9 @@ gp_libusb1_reset(GPPort *port)
{
C_PARAMS (port && port->pl->dh);
+ /* earlier libusb 1 versions get crashes otherwise */
+ _close_async_interrupts(port);
+
C_LIBUSB (libusb_reset_device (port->pl->dh), GP_ERROR_IO);
return GP_OK;