summaryrefslogtreecommitdiff
path: root/daemon/gvfsbackendmtp.c
diff options
context:
space:
mode:
authorPhilip Langdale <philipl@overt.org>2016-05-16 08:02:02 -0700
committerPhilip Langdale <philipl@overt.org>2016-11-04 21:38:14 -0700
commit07c635a0ed402d6fb7c309c83dbdb9c21fad93bc (patch)
tree2c3dfda0a7e8c30830cc54d6147bfbb977c8994a /daemon/gvfsbackendmtp.c
parent5637d4284295b961de2744a5a11026c71a9a45b0 (diff)
downloadgvfs-07c635a0ed402d6fb7c309c83dbdb9c21fad93bc.tar.gz
mtp: Use libusb interruption mechanism
Now that libusb 1.0.21 is finally out, there is a way to explicitly interrupt a thread that is waiting for events. This allows us to use a long timeout on our event waiting, which we can interrupt, rather than a short, one second, timeout. The only nuance is that we need to link against libusb directly to be able to use the interrupt mechanism. This is a little bit ugly, but is necessary unless libmtp wraps the interruption call.
Diffstat (limited to 'daemon/gvfsbackendmtp.c')
-rw-r--r--daemon/gvfsbackendmtp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 7570b6ab..dddc4d56 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -34,6 +34,9 @@
#include <gio/gio.h>
#include <libmtp.h>
+#if HAVE_LIBUSB
+#include <libusb.h>
+#endif
#include "gvfsbackendmtp.h"
#include "gvfsicon.h"
@@ -76,7 +79,11 @@
* Constants
************************************************/
+#if HAVE_LIBUSB
+#define EVENT_POLL_PERIOD { 3600, 0 }
+#else
#define EVENT_POLL_PERIOD { 1, 0 }
+#endif
/************************************************
* Private Types
@@ -959,6 +966,10 @@ do_unmount (GVfsBackend *backend, GVfsJobUnmount *job,
g_atomic_int_set (&op_backend->unmount_started, TRUE);
+#if HAVE_LIBUSB
+ libusb_interrupt_event_handler (NULL);
+#endif
+
#ifdef HAVE_LIBMTP_1_1_12
/* Thread will terminate after flag is set. */
g_thread_join (op_backend->event_thread);