aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2013-06-13 10:59:11 -0700
committerHans de Goede <hdegoede@redhat.com>2013-06-14 09:48:40 +0200
commit4d099d08a99aff38c72e393d7eef94b6436d39f8 (patch)
treea45ff1eb642fa86244e39c8aa4305ea01144f783
parent41091f7a6ba7b0243f064b1999f7b4af84f6c3cf (diff)
downloadandroid_external_libusbx-4d099d08a99aff38c72e393d7eef94b6436d39f8.tar.gz
android_external_libusbx-4d099d08a99aff38c72e393d7eef94b6436d39f8.tar.bz2
android_external_libusbx-4d099d08a99aff38c72e393d7eef94b6436d39f8.zip
hotplug: ensure udev monitor fd is non-blocking
Some older versions of udev do not automatically set the udev monitor fd to non-blocking mode. This patch ensures that this is always set. HdG: Get flags then or in O_NONBLOCK and set them, rather then setting flags to only O_NONBLOCK. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--libusb/os/linux_udev.c13
-rw-r--r--libusb/version_nano.h2
2 files changed, 14 insertions, 1 deletions
diff --git a/libusb/os/linux_udev.c b/libusb/os/linux_udev.c
index 27ee7ed..29c949a 100644
--- a/libusb/os/linux_udev.c
+++ b/libusb/os/linux_udev.c
@@ -82,6 +82,19 @@ int linux_udev_start_event_monitor(void)
udev_monitor_fd = udev_monitor_get_fd(udev_monitor);
+ /* Some older versions of udev are not non-blocking by default,
+ * so make sure this is set */
+ r = fcntl(udev_monitor_fd, F_GETFL);
+ if (r == -1) {
+ usbi_err(NULL, "getting udev monitor fd flags (%d)", errno);
+ goto err_free_monitor;
+ }
+ r = fcntl(udev_monitor_fd, F_SETFL, r | O_NONBLOCK);
+ if (r) {
+ usbi_err(NULL, "setting udev monitor fd flags (%d)", errno);
+ goto err_free_monitor;
+ }
+
r = pthread_create(&linux_event_thread, NULL, linux_udev_event_thread_main, NULL);
if (r) {
usbi_err(NULL, "creating hotplug event thread (%d)", r);
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index f115614..5d7f2b9 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 10735
+#define LIBUSB_NANO 10736