[arch-commits] Commit in libusbx/repos (10 files)
Tobias Powalowski
tpowa at nymeria.archlinux.org
Tue Aug 6 15:03:06 UTC 2013
Date: Tuesday, August 6, 2013 @ 17:03:05
Author: tpowa
Revision: 192163
db-move: moved libusbx from [testing] to [core] (i686, x86_64)
Added:
libusbx/repos/core-i686/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch
(from rev 192162, libusbx/repos/testing-i686/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch)
libusbx/repos/core-i686/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch
(from rev 192162, libusbx/repos/testing-i686/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch)
libusbx/repos/core-i686/PKGBUILD
(from rev 192162, libusbx/repos/testing-i686/PKGBUILD)
libusbx/repos/core-x86_64/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch
(from rev 192162, libusbx/repos/testing-x86_64/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch)
libusbx/repos/core-x86_64/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch
(from rev 192162, libusbx/repos/testing-x86_64/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch)
libusbx/repos/core-x86_64/PKGBUILD
(from rev 192162, libusbx/repos/testing-x86_64/PKGBUILD)
Deleted:
libusbx/repos/core-i686/PKGBUILD
libusbx/repos/core-x86_64/PKGBUILD
libusbx/repos/testing-i686/
libusbx/repos/testing-x86_64/
-----------------------------------------------------------------------------+
/PKGBUILD | 84 +++++
core-i686/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch | 103 +++++++
core-i686/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch | 141 ++++++++++
core-i686/PKGBUILD | 32 --
core-x86_64/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch | 103 +++++++
core-x86_64/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch | 141 ++++++++++
core-x86_64/PKGBUILD | 32 --
7 files changed, 572 insertions(+), 64 deletions(-)
Copied: libusbx/repos/core-i686/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch (from rev 192162, libusbx/repos/testing-i686/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch)
===================================================================
--- core-i686/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch (rev 0)
+++ core-i686/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch 2013-08-06 15:03:05 UTC (rev 192163)
@@ -0,0 +1,103 @@
+From daf4c9fadaf8a49198c53c039bf78980dc251a4b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Tue, 30 Jul 2013 15:57:16 +0200
+Subject: [PATCH 1/2] linux: Use a separate lock to serialize start/stop vs
+ hotplug events
+
+Using one lock for this is a bad idea, as we should not be holding any
+locks used by the hotplug thread when trying to stop otherwise the stop
+function may wait indefinetely in pthread_join, while the event-thread
+is waiting for the lock the caller of the stop function holds.
+
+Using 2 separate locks for this should fix this deadlock, which has been
+reported here: https://bugzilla.redhat.com/show_bug.cgi?id=985484
+
+Many thanks to Chris Dickens for figuring out the cause of this deadlock!
+
+CC: Chris Dickens <christopher.a.dickens at gmail.com>
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ libusb/os/linux_usbfs.c | 24 +++++++++++++++++-------
+ libusb/version_nano.h | 2 +-
+ 2 files changed, 18 insertions(+), 8 deletions(-)
+
+diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
+index 09288af..90e23b7 100644
+--- a/libusb/os/linux_usbfs.c
++++ b/libusb/os/linux_usbfs.c
+@@ -120,7 +120,9 @@ static int sysfs_has_descriptors = -1;
+ /* how many times have we initted (and not exited) ? */
+ static volatile int init_count = 0;
+
+-/* Serialize hotplug start/stop, scan-devices, event-thread, and poll */
++/* Serialize hotplug start/stop */
++usbi_mutex_static_t linux_hotplug_startstop_lock = USBI_MUTEX_INITIALIZER;
++/* Serialize scan-devices, event-thread, and poll */
+ usbi_mutex_static_t linux_hotplug_lock = USBI_MUTEX_INITIALIZER;
+
+ static int linux_start_event_monitor(void);
+@@ -419,7 +421,7 @@ static int op_init(struct libusb_context *ctx)
+ if (sysfs_has_descriptors)
+ usbi_dbg("sysfs has complete descriptors");
+
+- usbi_mutex_static_lock(&linux_hotplug_lock);
++ usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
+ r = LIBUSB_SUCCESS;
+ if (init_count == 0) {
+ /* start up hotplug event handler */
+@@ -433,20 +435,20 @@ static int op_init(struct libusb_context *ctx)
+ linux_stop_event_monitor();
+ } else
+ usbi_err(ctx, "error starting hotplug event monitor");
+- usbi_mutex_static_unlock(&linux_hotplug_lock);
++ usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
+
+ return r;
+ }
+
+ static void op_exit(void)
+ {
+- usbi_mutex_static_lock(&linux_hotplug_lock);
++ usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
+ assert(init_count != 0);
+ if (!--init_count) {
+ /* tear down event handler */
+ (void)linux_stop_event_monitor();
+ }
+- usbi_mutex_static_unlock(&linux_hotplug_lock);
++ usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
+ }
+
+ static int linux_start_event_monitor(void)
+@@ -469,11 +471,19 @@ static int linux_stop_event_monitor(void)
+
+ static int linux_scan_devices(struct libusb_context *ctx)
+ {
++ int ret;
++
++ usbi_mutex_static_lock(&linux_hotplug_lock);
++
+ #if defined(USE_UDEV)
+- return linux_udev_scan_devices(ctx);
++ ret = linux_udev_scan_devices(ctx);
+ #else
+- return linux_default_scan_devices(ctx);
++ ret = linux_default_scan_devices(ctx);
+ #endif
++
++ usbi_mutex_static_unlock(&linux_hotplug_lock);
++
++ return ret;
+ }
+
+ static void op_hotplug_poll(void)
+diff --git a/libusb/version_nano.h b/libusb/version_nano.h
+index ebf41e1..34e26ff 100644
+--- a/libusb/version_nano.h
++++ b/libusb/version_nano.h
+@@ -1 +1 @@
+-#define LIBUSB_NANO 10774
++#define LIBUSB_NANO 10777
+--
+1.8.3.1
+
Copied: libusbx/repos/core-i686/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch (from rev 192162, libusbx/repos/testing-i686/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch)
===================================================================
--- core-i686/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch (rev 0)
+++ core-i686/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch 2013-08-06 15:03:05 UTC (rev 192163)
@@ -0,0 +1,141 @@
+From 852efb5a3e82de43cf6288e9904cb254ff636aa0 Mon Sep 17 00:00:00 2001
+From: Chris Dickens <christopher.a.dickens at gmail.com>
+Date: Sat, 20 Jul 2013 13:01:41 -0700
+Subject: [PATCH 2/2] hotplug: Remove use of pthread_cancel from linux_udev
+
+Using pthread_cancel() presents the opportunity for deadlock, so
+use a control pipe to cause the event thread to gracefully exit.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ libusb/os/linux_udev.c | 63 ++++++++++++++++++++++++++++++++++++++------------
+ libusb/version_nano.h | 2 +-
+ 2 files changed, 49 insertions(+), 16 deletions(-)
+
+diff --git a/libusb/os/linux_udev.c b/libusb/os/linux_udev.c
+index 5a2aadf..70f632d 100644
+--- a/libusb/os/linux_udev.c
++++ b/libusb/os/linux_udev.c
+@@ -46,6 +46,7 @@
+ /* udev context */
+ static struct udev *udev_ctx = NULL;
+ static int udev_monitor_fd = -1;
++static int udev_control_pipe[2] = {-1, -1};
+ static struct udev_monitor *udev_monitor = NULL;
+ static pthread_t linux_event_thread;
+
+@@ -95,14 +96,23 @@ int linux_udev_start_event_monitor(void)
+ goto err_free_monitor;
+ }
+
++ r = usbi_pipe(udev_control_pipe);
++ if (r) {
++ usbi_err(NULL, "could not create udev control pipe");
++ 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);
+- goto err_free_monitor;
++ goto err_close_pipe;
+ }
+
+ return LIBUSB_SUCCESS;
+
++err_close_pipe:
++ close(udev_control_pipe[0]);
++ close(udev_control_pipe[1]);
+ err_free_monitor:
+ udev_monitor_unref(udev_monitor);
+ udev_monitor = NULL;
+@@ -115,14 +125,19 @@ err_free_ctx:
+
+ int linux_udev_stop_event_monitor(void)
+ {
++ char dummy = 1;
++ int r;
++
+ assert(udev_ctx != NULL);
+ assert(udev_monitor != NULL);
+ assert(udev_monitor_fd != -1);
+
+- /* Cancel the event thread. This is the only way to guarantee the
+- thread exits since closing the monitor fd won't necessarily cause
+- poll to return. */
+- pthread_cancel(linux_event_thread);
++ /* Write some dummy data to the control pipe and
++ * wait for the thread to exit */
++ r = usbi_write(udev_control_pipe[1], &dummy, sizeof(dummy));
++ if (r <= 0) {
++ usbi_warn(NULL, "udev control pipe signal failed");
++ }
+ pthread_join(linux_event_thread, NULL);
+
+ /* Release the udev monitor */
+@@ -134,27 +149,45 @@ int linux_udev_stop_event_monitor(void)
+ udev_unref(udev_ctx);
+ udev_ctx = NULL;
+
++ /* close and reset control pipe */
++ close(udev_control_pipe[0]);
++ close(udev_control_pipe[1]);
++ udev_control_pipe[0] = -1;
++ udev_control_pipe[1] = -1;
++
+ return LIBUSB_SUCCESS;
+ }
+
+ static void *linux_udev_event_thread_main(void *arg)
+ {
++ char dummy;
++ int r;
+ struct udev_device* udev_dev;
+- struct pollfd fds = {.fd = udev_monitor_fd,
+- .events = POLLIN};
++ struct pollfd fds[] = {
++ {.fd = udev_control_pipe[0],
++ .events = POLLIN},
++ {.fd = udev_monitor_fd,
++ .events = POLLIN},
++ };
+
+ usbi_dbg("udev event thread entering.");
+
+- while (1 == poll(&fds, 1, -1)) {
+- if (NULL == udev_monitor || POLLIN != fds.revents) {
++ while (poll(fds, 2, -1) >= 0) {
++ if (fds[0].revents & POLLIN) {
++ /* activity on control pipe, read the byte and exit */
++ r = usbi_read(udev_control_pipe[0], &dummy, sizeof(dummy));
++ if (r <= 0) {
++ usbi_warn(NULL, "udev control pipe read failed");
++ }
+ break;
+ }
+-
+- usbi_mutex_static_lock(&linux_hotplug_lock);
+- udev_dev = udev_monitor_receive_device(udev_monitor);
+- if (udev_dev)
+- udev_hotplug_event(udev_dev);
+- usbi_mutex_static_unlock(&linux_hotplug_lock);
++ if (fds[1].revents & POLLIN) {
++ usbi_mutex_static_lock(&linux_hotplug_lock);
++ udev_dev = udev_monitor_receive_device(udev_monitor);
++ if (udev_dev)
++ udev_hotplug_event(udev_dev);
++ usbi_mutex_static_unlock(&linux_hotplug_lock);
++ }
+ }
+
+ usbi_dbg("udev event thread exiting");
+diff --git a/libusb/version_nano.h b/libusb/version_nano.h
+index 34e26ff..39ad7e3 100644
+--- a/libusb/version_nano.h
++++ b/libusb/version_nano.h
+@@ -1 +1 @@
+-#define LIBUSB_NANO 10777
++#define LIBUSB_NANO 10778
+--
+1.8.3.1
+
Deleted: core-i686/PKGBUILD
===================================================================
--- core-i686/PKGBUILD 2013-08-06 14:54:27 UTC (rev 192162)
+++ core-i686/PKGBUILD 2013-08-06 15:03:05 UTC (rev 192163)
@@ -1,32 +0,0 @@
-# $Id$
-# Maintainer: Tobias Powalowski <tpowa at archlinux.org>
-pkgname=libusbx
-pkgver=1.0.16
-pkgrel=1
-depends=('glibc' 'systemd')
-pkgdesc="Library that provides generic access to USB device"
-arch=(i686 x86_64)
-url="http://libusbx.org"
-license=('LGPL')
-source=(http://downloads.sourceforge.net/${pkgname}/releases/${pkgver}/${pkgname}-${pkgver}.tar.bz2)
-options=(!libtool)
-replaces=('libusb1' 'libusb')
-provides=("libusb=$pkgver")
-conflicts=("libusb")
-
-build() {
- cd "${srcdir}/${pkgname}-${pkgver}"
- ./configure --prefix=/usr --disable-static
- make
-}
-
-check() {
- cd "${srcdir}/${pkgname}-${pkgver}"
- make check
-}
-
-package () {
- cd "${srcdir}/${pkgname}-${pkgver}"
- make DESTDIR="${pkgdir}" install
-}
-md5sums=('7f5715d624cd6c26b30a317eb6c2fe5e')
Copied: libusbx/repos/core-i686/PKGBUILD (from rev 192162, libusbx/repos/testing-i686/PKGBUILD)
===================================================================
--- core-i686/PKGBUILD (rev 0)
+++ core-i686/PKGBUILD 2013-08-06 15:03:05 UTC (rev 192163)
@@ -0,0 +1,42 @@
+# $Id$
+# Maintainer: Tobias Powalowski <tpowa at archlinux.org>
+pkgname=libusbx
+pkgver=1.0.16
+pkgrel=2
+depends=('glibc' 'systemd')
+pkgdesc="Library that provides generic access to USB device"
+arch=(i686 x86_64)
+url="http://libusbx.org"
+license=('LGPL')
+source=(http://downloads.sourceforge.net/${pkgname}/releases/${pkgver}/${pkgname}-${pkgver}.tar.bz2
+ 0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch
+ 0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch)
+options=(!libtool)
+replaces=('libusb1' 'libusb')
+provides=("libusb=$pkgver")
+conflicts=("libusb")
+md5sums=('7f5715d624cd6c26b30a317eb6c2fe5e'
+ 'dad04322621fe7cabd2fe631c6d9929f'
+ '259238c92c92f8b3df5dcad0db8aaf2f')
+
+prepare() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ # fix #36418
+ patch -Np1 -i ../0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch
+ patch -Np1 -i ../0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch
+}
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr --disable-static
+ make
+}
+
+check() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make check
+}
+
+package () {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+}
Copied: libusbx/repos/core-x86_64/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch (from rev 192162, libusbx/repos/testing-x86_64/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch)
===================================================================
--- core-x86_64/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch (rev 0)
+++ core-x86_64/0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch 2013-08-06 15:03:05 UTC (rev 192163)
@@ -0,0 +1,103 @@
+From daf4c9fadaf8a49198c53c039bf78980dc251a4b Mon Sep 17 00:00:00 2001
+From: Hans de Goede <hdegoede at redhat.com>
+Date: Tue, 30 Jul 2013 15:57:16 +0200
+Subject: [PATCH 1/2] linux: Use a separate lock to serialize start/stop vs
+ hotplug events
+
+Using one lock for this is a bad idea, as we should not be holding any
+locks used by the hotplug thread when trying to stop otherwise the stop
+function may wait indefinetely in pthread_join, while the event-thread
+is waiting for the lock the caller of the stop function holds.
+
+Using 2 separate locks for this should fix this deadlock, which has been
+reported here: https://bugzilla.redhat.com/show_bug.cgi?id=985484
+
+Many thanks to Chris Dickens for figuring out the cause of this deadlock!
+
+CC: Chris Dickens <christopher.a.dickens at gmail.com>
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ libusb/os/linux_usbfs.c | 24 +++++++++++++++++-------
+ libusb/version_nano.h | 2 +-
+ 2 files changed, 18 insertions(+), 8 deletions(-)
+
+diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
+index 09288af..90e23b7 100644
+--- a/libusb/os/linux_usbfs.c
++++ b/libusb/os/linux_usbfs.c
+@@ -120,7 +120,9 @@ static int sysfs_has_descriptors = -1;
+ /* how many times have we initted (and not exited) ? */
+ static volatile int init_count = 0;
+
+-/* Serialize hotplug start/stop, scan-devices, event-thread, and poll */
++/* Serialize hotplug start/stop */
++usbi_mutex_static_t linux_hotplug_startstop_lock = USBI_MUTEX_INITIALIZER;
++/* Serialize scan-devices, event-thread, and poll */
+ usbi_mutex_static_t linux_hotplug_lock = USBI_MUTEX_INITIALIZER;
+
+ static int linux_start_event_monitor(void);
+@@ -419,7 +421,7 @@ static int op_init(struct libusb_context *ctx)
+ if (sysfs_has_descriptors)
+ usbi_dbg("sysfs has complete descriptors");
+
+- usbi_mutex_static_lock(&linux_hotplug_lock);
++ usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
+ r = LIBUSB_SUCCESS;
+ if (init_count == 0) {
+ /* start up hotplug event handler */
+@@ -433,20 +435,20 @@ static int op_init(struct libusb_context *ctx)
+ linux_stop_event_monitor();
+ } else
+ usbi_err(ctx, "error starting hotplug event monitor");
+- usbi_mutex_static_unlock(&linux_hotplug_lock);
++ usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
+
+ return r;
+ }
+
+ static void op_exit(void)
+ {
+- usbi_mutex_static_lock(&linux_hotplug_lock);
++ usbi_mutex_static_lock(&linux_hotplug_startstop_lock);
+ assert(init_count != 0);
+ if (!--init_count) {
+ /* tear down event handler */
+ (void)linux_stop_event_monitor();
+ }
+- usbi_mutex_static_unlock(&linux_hotplug_lock);
++ usbi_mutex_static_unlock(&linux_hotplug_startstop_lock);
+ }
+
+ static int linux_start_event_monitor(void)
+@@ -469,11 +471,19 @@ static int linux_stop_event_monitor(void)
+
+ static int linux_scan_devices(struct libusb_context *ctx)
+ {
++ int ret;
++
++ usbi_mutex_static_lock(&linux_hotplug_lock);
++
+ #if defined(USE_UDEV)
+- return linux_udev_scan_devices(ctx);
++ ret = linux_udev_scan_devices(ctx);
+ #else
+- return linux_default_scan_devices(ctx);
++ ret = linux_default_scan_devices(ctx);
+ #endif
++
++ usbi_mutex_static_unlock(&linux_hotplug_lock);
++
++ return ret;
+ }
+
+ static void op_hotplug_poll(void)
+diff --git a/libusb/version_nano.h b/libusb/version_nano.h
+index ebf41e1..34e26ff 100644
+--- a/libusb/version_nano.h
++++ b/libusb/version_nano.h
+@@ -1 +1 @@
+-#define LIBUSB_NANO 10774
++#define LIBUSB_NANO 10777
+--
+1.8.3.1
+
Copied: libusbx/repos/core-x86_64/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch (from rev 192162, libusbx/repos/testing-x86_64/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch)
===================================================================
--- core-x86_64/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch (rev 0)
+++ core-x86_64/0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch 2013-08-06 15:03:05 UTC (rev 192163)
@@ -0,0 +1,141 @@
+From 852efb5a3e82de43cf6288e9904cb254ff636aa0 Mon Sep 17 00:00:00 2001
+From: Chris Dickens <christopher.a.dickens at gmail.com>
+Date: Sat, 20 Jul 2013 13:01:41 -0700
+Subject: [PATCH 2/2] hotplug: Remove use of pthread_cancel from linux_udev
+
+Using pthread_cancel() presents the opportunity for deadlock, so
+use a control pipe to cause the event thread to gracefully exit.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+---
+ libusb/os/linux_udev.c | 63 ++++++++++++++++++++++++++++++++++++++------------
+ libusb/version_nano.h | 2 +-
+ 2 files changed, 49 insertions(+), 16 deletions(-)
+
+diff --git a/libusb/os/linux_udev.c b/libusb/os/linux_udev.c
+index 5a2aadf..70f632d 100644
+--- a/libusb/os/linux_udev.c
++++ b/libusb/os/linux_udev.c
+@@ -46,6 +46,7 @@
+ /* udev context */
+ static struct udev *udev_ctx = NULL;
+ static int udev_monitor_fd = -1;
++static int udev_control_pipe[2] = {-1, -1};
+ static struct udev_monitor *udev_monitor = NULL;
+ static pthread_t linux_event_thread;
+
+@@ -95,14 +96,23 @@ int linux_udev_start_event_monitor(void)
+ goto err_free_monitor;
+ }
+
++ r = usbi_pipe(udev_control_pipe);
++ if (r) {
++ usbi_err(NULL, "could not create udev control pipe");
++ 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);
+- goto err_free_monitor;
++ goto err_close_pipe;
+ }
+
+ return LIBUSB_SUCCESS;
+
++err_close_pipe:
++ close(udev_control_pipe[0]);
++ close(udev_control_pipe[1]);
+ err_free_monitor:
+ udev_monitor_unref(udev_monitor);
+ udev_monitor = NULL;
+@@ -115,14 +125,19 @@ err_free_ctx:
+
+ int linux_udev_stop_event_monitor(void)
+ {
++ char dummy = 1;
++ int r;
++
+ assert(udev_ctx != NULL);
+ assert(udev_monitor != NULL);
+ assert(udev_monitor_fd != -1);
+
+- /* Cancel the event thread. This is the only way to guarantee the
+- thread exits since closing the monitor fd won't necessarily cause
+- poll to return. */
+- pthread_cancel(linux_event_thread);
++ /* Write some dummy data to the control pipe and
++ * wait for the thread to exit */
++ r = usbi_write(udev_control_pipe[1], &dummy, sizeof(dummy));
++ if (r <= 0) {
++ usbi_warn(NULL, "udev control pipe signal failed");
++ }
+ pthread_join(linux_event_thread, NULL);
+
+ /* Release the udev monitor */
+@@ -134,27 +149,45 @@ int linux_udev_stop_event_monitor(void)
+ udev_unref(udev_ctx);
+ udev_ctx = NULL;
+
++ /* close and reset control pipe */
++ close(udev_control_pipe[0]);
++ close(udev_control_pipe[1]);
++ udev_control_pipe[0] = -1;
++ udev_control_pipe[1] = -1;
++
+ return LIBUSB_SUCCESS;
+ }
+
+ static void *linux_udev_event_thread_main(void *arg)
+ {
++ char dummy;
++ int r;
+ struct udev_device* udev_dev;
+- struct pollfd fds = {.fd = udev_monitor_fd,
+- .events = POLLIN};
++ struct pollfd fds[] = {
++ {.fd = udev_control_pipe[0],
++ .events = POLLIN},
++ {.fd = udev_monitor_fd,
++ .events = POLLIN},
++ };
+
+ usbi_dbg("udev event thread entering.");
+
+- while (1 == poll(&fds, 1, -1)) {
+- if (NULL == udev_monitor || POLLIN != fds.revents) {
++ while (poll(fds, 2, -1) >= 0) {
++ if (fds[0].revents & POLLIN) {
++ /* activity on control pipe, read the byte and exit */
++ r = usbi_read(udev_control_pipe[0], &dummy, sizeof(dummy));
++ if (r <= 0) {
++ usbi_warn(NULL, "udev control pipe read failed");
++ }
+ break;
+ }
+-
+- usbi_mutex_static_lock(&linux_hotplug_lock);
+- udev_dev = udev_monitor_receive_device(udev_monitor);
+- if (udev_dev)
+- udev_hotplug_event(udev_dev);
+- usbi_mutex_static_unlock(&linux_hotplug_lock);
++ if (fds[1].revents & POLLIN) {
++ usbi_mutex_static_lock(&linux_hotplug_lock);
++ udev_dev = udev_monitor_receive_device(udev_monitor);
++ if (udev_dev)
++ udev_hotplug_event(udev_dev);
++ usbi_mutex_static_unlock(&linux_hotplug_lock);
++ }
+ }
+
+ usbi_dbg("udev event thread exiting");
+diff --git a/libusb/version_nano.h b/libusb/version_nano.h
+index 34e26ff..39ad7e3 100644
+--- a/libusb/version_nano.h
++++ b/libusb/version_nano.h
+@@ -1 +1 @@
+-#define LIBUSB_NANO 10777
++#define LIBUSB_NANO 10778
+--
+1.8.3.1
+
Deleted: core-x86_64/PKGBUILD
===================================================================
--- core-x86_64/PKGBUILD 2013-08-06 14:54:27 UTC (rev 192162)
+++ core-x86_64/PKGBUILD 2013-08-06 15:03:05 UTC (rev 192163)
@@ -1,32 +0,0 @@
-# $Id$
-# Maintainer: Tobias Powalowski <tpowa at archlinux.org>
-pkgname=libusbx
-pkgver=1.0.16
-pkgrel=1
-depends=('glibc' 'systemd')
-pkgdesc="Library that provides generic access to USB device"
-arch=(i686 x86_64)
-url="http://libusbx.org"
-license=('LGPL')
-source=(http://downloads.sourceforge.net/${pkgname}/releases/${pkgver}/${pkgname}-${pkgver}.tar.bz2)
-options=(!libtool)
-replaces=('libusb1' 'libusb')
-provides=("libusb=$pkgver")
-conflicts=("libusb")
-
-build() {
- cd "${srcdir}/${pkgname}-${pkgver}"
- ./configure --prefix=/usr --disable-static
- make
-}
-
-check() {
- cd "${srcdir}/${pkgname}-${pkgver}"
- make check
-}
-
-package () {
- cd "${srcdir}/${pkgname}-${pkgver}"
- make DESTDIR="${pkgdir}" install
-}
-md5sums=('7f5715d624cd6c26b30a317eb6c2fe5e')
Copied: libusbx/repos/core-x86_64/PKGBUILD (from rev 192162, libusbx/repos/testing-x86_64/PKGBUILD)
===================================================================
--- core-x86_64/PKGBUILD (rev 0)
+++ core-x86_64/PKGBUILD 2013-08-06 15:03:05 UTC (rev 192163)
@@ -0,0 +1,42 @@
+# $Id$
+# Maintainer: Tobias Powalowski <tpowa at archlinux.org>
+pkgname=libusbx
+pkgver=1.0.16
+pkgrel=2
+depends=('glibc' 'systemd')
+pkgdesc="Library that provides generic access to USB device"
+arch=(i686 x86_64)
+url="http://libusbx.org"
+license=('LGPL')
+source=(http://downloads.sourceforge.net/${pkgname}/releases/${pkgver}/${pkgname}-${pkgver}.tar.bz2
+ 0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch
+ 0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch)
+options=(!libtool)
+replaces=('libusb1' 'libusb')
+provides=("libusb=$pkgver")
+conflicts=("libusb")
+md5sums=('7f5715d624cd6c26b30a317eb6c2fe5e'
+ 'dad04322621fe7cabd2fe631c6d9929f'
+ '259238c92c92f8b3df5dcad0db8aaf2f')
+
+prepare() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ # fix #36418
+ patch -Np1 -i ../0001-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch
+ patch -Np1 -i ../0002-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch
+}
+build() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ ./configure --prefix=/usr --disable-static
+ make
+}
+
+check() {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make check
+}
+
+package () {
+ cd "${srcdir}/${pkgname}-${pkgver}"
+ make DESTDIR="${pkgdir}" install
+}
More information about the arch-commits
mailing list