diff options
author | Samuli Suominen <ssuominen@gentoo.org> | 2013-08-05 13:34:14 +0000 |
---|---|---|
committer | Samuli Suominen <ssuominen@gentoo.org> | 2013-08-05 13:34:14 +0000 |
commit | f912a650840dd8b0152923ec64296bc03b9b04bd (patch) | |
tree | ac6ac5c32ab6ced3a34c7633d28a2b69894d0950 /dev-libs | |
parent | Remove old. (diff) | |
download | historical-f912a650840dd8b0152923ec64296bc03b9b04bd.tar.gz historical-f912a650840dd8b0152923ec64296bc03b9b04bd.tar.bz2 historical-f912a650840dd8b0152923ec64296bc03b9b04bd.zip |
Fix libusb_exit deadlock by backporting two upstream fixes.
Package-Manager: portage-2.2.0_alpha191/cvs/Linux x86_64
Manifest-Sign-Key: 0x4868F14D
Diffstat (limited to 'dev-libs')
5 files changed, 330 insertions, 9 deletions
diff --git a/dev-libs/libusbx/ChangeLog b/dev-libs/libusbx/ChangeLog index 5c4a57f9f5e1..e02f6e76b2f1 100644 --- a/dev-libs/libusbx/ChangeLog +++ b/dev-libs/libusbx/ChangeLog @@ -1,6 +1,16 @@ # ChangeLog for dev-libs/libusbx # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-libs/libusbx/ChangeLog,v 1.14 2013/08/01 12:32:23 ssuominen Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-libs/libusbx/ChangeLog,v 1.15 2013/08/05 13:34:08 ssuominen Exp $ + +*libusbx-1.0.16-r2 (05 Aug 2013) + + 05 Aug 2013; Samuli Suominen <ssuominen@gentoo.org> + +libusbx-1.0.16-r2.ebuild, + +files/libusbx-1.0.16-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.pa + tch, + +files/libusbx-1.0.16-linux-Use-a-separate-lock-to-serialize-start-stop-vs.pa + tch: + Fix libusb_exit deadlock by backporting two upstream fixes. *libusbx-1.0.16-r1 (01 Aug 2013) diff --git a/dev-libs/libusbx/Manifest b/dev-libs/libusbx/Manifest index e3792ad2614e..15c79ff9344b 100644 --- a/dev-libs/libusbx/Manifest +++ b/dev-libs/libusbx/Manifest @@ -1,21 +1,24 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 +AUX libusbx-1.0.16-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch 4089 SHA256 eac68f07c3de3dd30316f8de798cae1f26a030de3049540bb9e1bb7a3792e48c SHA512 136ed1e42220dfb639d214a007d714c3c113599431dc7b75d2eabf523ff0f5e9c407a0d8e26cc523db3e87b9d9e130f1932bdd60e5b48e8de0633fbc7392ea22 WHIRLPOOL 19a92baab59f449e71bf471e97a123bc53aa6116d16bf573e16a58e10dfeec795f4a7188bf1afc05ceba722114c502603a0d158fe70ee9a95689548360b404e2 +AUX libusbx-1.0.16-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch 3409 SHA256 2bcd9c31b66e80644fe426eac3beedbe8b2c632fe41d2f4c2629c4ed799a8817 SHA512 565f58a3a4a698f0a72e4d5f2252455f9d95f79e30a4f611dad03967f9ab3290f466422bcab7c011bc2659d5f1ad8d351d6d7fd28f55471575c19ef5ca0c3087 WHIRLPOOL 8d866d5750d5773909d73ba641e77c175bff453f8d5b5b490d19f45c37689426e8f961210a6f76d9097d0288780551406ed1025c1baae3821cf86e1d7973a3b5 DIST libusbx-1.0.15.tar.bz2 455939 SHA256 bb5ec30e53e007d13c37b4edd929435ac224bb71b8fc08fa37ec9e3e81037963 SHA512 7bead1b6407b294ed4a258a3c4d005601c0195960fda1ca35669e64939eb9b58f82738d021f90e55ab4854dd8c78571eb6a77a4ca37896987b14155d33165a3a WHIRLPOOL 2bd07e15506f72147af10e23250d3bb4fe9cbfaa1d2e5a1d21d1efd2d51cb246244cf45a3693c46a736f8e716ec12ff71107a2ec1bd84876fb0244d7f7af95c4 DIST libusbx-1.0.16.tar.bz2 488428 SHA256 5b335cf9572d793da6ced55bce633894288a8ff39557f07ccc798f2cb74cb580 SHA512 a92fd006afab80c051edc725105bbf1c7b79bdc050fde750d81bf050195e1f19be6217682c0cdf047754eed1be5848c915aac3d5364acc72a8324ce0f8b9e698 WHIRLPOOL dc25709f8f838c28306f6838f23e4907b7f8d1f8b5dd0ec14c649d79f15ed23942a6457034fe2ae25606ed6a584efa41fed6233e6be09e1965a6aa95b5a303ae EBUILD libusbx-1.0.15.ebuild 1202 SHA256 43763c3d75bb384ea1bdeacdd98b6cfe08cbb17add1e79faf10cbd51afd48ee4 SHA512 ee1776f9caf184a8b0acaff62d5b97c7d58ea1acdf3e179b67735531d3056c6e520eeee6323564eac7a56f98a764c7b1c46f1387835a8c4b087bb28bd6ff533e WHIRLPOOL 317f59833ac00def9c4c5846e56a8adc459299c10f760d529241a1a99682d37ac04afbbc475e039ae53a0125c230e058ad1da3b935837399ee3346def1c6872d EBUILD libusbx-1.0.16-r1.ebuild 1321 SHA256 69a3b827b4f200093de2e97be5e4441eb4f0b927db52f19291dcb5824b771909 SHA512 4b0afbd415297c00112324c7a4eedcb0052cf615dce87ed38d0a9ea9cd9e90a7a1628687ab2252d68348707041e037581cf4aa842a2bacd1b9ba31d5f67e3ca1 WHIRLPOOL f972b8329163d53f085c982ce6e7dcea4773a585ffe6bd74f9615ce8ed3c10257fdcf389eadb39943bb69af132ff1d8435d18ac0016528e5a24d582307072bfc +EBUILD libusbx-1.0.16-r2.ebuild 1512 SHA256 7b8141c1f6fd3deaf0e8464f61107abd2f90163ec35b4b80349b53e3dfb0d654 SHA512 2cf383e21e1911a560ce614773fd30803a24552f73c92d35a57f1967f8c9af117320fddfc67ab5604e093f8c4fcb817ef4de04bd4b874943d5f3d94033978dbb WHIRLPOOL 720991d9f5bc7b696669e50604e83a943ddc3efe63613af9588a6bf9121c314c892b6183817cb70529aebd5ef5789cf102792ac16f44e9583e4ee5e3a9cb5902 EBUILD libusbx-1.0.16.ebuild 1272 SHA256 568d60fe52191a2427736b984c948ba938fa50476de10307b6b730ae0e632530 SHA512 6f6d9e57f2e4298a7a8b99257fcb7393a62cf936f3657e71eda0936aaff177f5375cfe2ebcc21fe08b35e57d5eda9e1c2f7721bad9c516d4f19ae101f8e032d3 WHIRLPOOL aa99f41e492aafa5ce706aada9c3a584e8ba5790af4f1a379f563d1d9bd2edce51f8ae335d2c0df8f3231bec084d3920b948afc324ead5788c3e4e037f035589 -MISC ChangeLog 2031 SHA256 c021e59ea167344f3bbf9bc13e305c161dbe3deb894d16f5530abadc2e068491 SHA512 8ece5eeb422dedf89fb813d641f974e5a8b717520f7998886d561e76d4c78445e90c34297e2fd582c4b4fe17d45426f5b3dbb9cf845906836f567854f8e93498 WHIRLPOOL 568e38282c68ff784d4f77db37169e6c3b0f4b89fa9b9ae17b8395b6345f1e1f1b8ec05cc45f38a977799f8594693b778b8042c0756d7970a7a52073fa55e11a +MISC ChangeLog 2385 SHA256 3dc968462798e35beed9842ee97aff7207a81e7d815aa322375673a865eec3cf SHA512 23ae8f99efff0caa4e7737dcfc0dc390cd1f061409afc7ce0c315840b96758c3893e0b1c4edc369616d3b8046e944b645537277c1022d34ae414cb3f7f2dcfe3 WHIRLPOOL 86c4a79c809a08287a5f8080050c7a5ba95a8e32b45ee06e30632dc2174922ee7a8b42aa1e8ba58046b67565b45893aa176169413718c16de8c835966c1524c3 MISC metadata.xml 285 SHA256 8f3e4e1f792ef6a6f383ae0aac1627db7f536ff880da423bca1113cea6d06773 SHA512 10fc61b3654c9aee6e9ba9702cf6630928921d2670248b9e1356d417b205dabc959e3672eda071f5fa734b3a001992cecd514a920b6e37376db943266683e75d WHIRLPOOL e26de64dba56ea85587b9e7348a1be056f78a2e2f9f91ffb5faef242b7ced82496b40fe672b18c33491f40a124161ca47af0e80219ebe39a8b24e86557c36db1 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) -iQEcBAEBCAAGBQJR+lUAAAoJEEdUh39IaPFNfRcH/2CX2HovzdtZUVzg10pyO4BC -Ww6CURU5TvIpmuWZqiwjTKsbLGmgGbjz/u83eEimcN8KYjEDE9AMFAtvOcyX0NIk -osNUTKNbPKe5qtH3PfIQ+XlGTUdLjp8bxR90fL0rtbP/61E320V2uqRQaf5SV/B/ -i+Fm62uMhjcs7nUemuaKo+x3G8eVUmVZxelWfqaBCbZewZI36M259Vj9snqddsWf -DyagpzzfQYDVLzF5SDcRSJXMAyFGtXn7GVfYhtXSv0FVVKahEdkxsJ0xYq5a0Nww -lSQbRHQJjOCqHwZLwtPz8Ad/P5QDVbvdHZZsO7g85X4sh2gQ3LtDKyRAOiT0hog= -=fzlb +iQEcBAEBCAAGBQJR/6lqAAoJEEdUh39IaPFN3SgH/2XNGQXAATsMvmL73M+WXbp/ +pV9me4gCOxmJkKT7G2AyeYvlhEFSlwWkza0SceCsPqgXFnFIfTsopV6RFOpbvWws +OaRXalqY4pcS6jjyLxLWEhsdMj0uKpDQl20izXr0Mvv101lJdfBWgOLOTuik3/s5 +Y4Kgy5nhFUxsnAllyDs+G/ROS4aJsnxsXf/JNmVDxXzuPicMRNSH2AMolTZ+86Th +Yv4CrLws+Mwldbrp79UZbwfY9WTCef+0FPOeCeD+hbClQqxBryk2vl9upzzGk2Yg +aW9h/L2pGrrrjMcjo7ZRYaba7GHGl56EEF1KRKXNzrq782KVwFKJFM+y48RvAg8= +=A5Nj -----END PGP SIGNATURE----- diff --git a/dev-libs/libusbx/files/libusbx-1.0.16-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch b/dev-libs/libusbx/files/libusbx-1.0.16-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch new file mode 100644 index 000000000000..5342fbe7005b --- /dev/null +++ b/dev-libs/libusbx/files/libusbx-1.0.16-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch @@ -0,0 +1,141 @@ +From 852efb5a3e82de43cf6288e9904cb254ff636aa0 Mon Sep 17 00:00:00 2001 +From: Chris Dickens <christopher.a.dickens@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@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 + diff --git a/dev-libs/libusbx/files/libusbx-1.0.16-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch b/dev-libs/libusbx/files/libusbx-1.0.16-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch new file mode 100644 index 000000000000..b66abd48f3a5 --- /dev/null +++ b/dev-libs/libusbx/files/libusbx-1.0.16-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch @@ -0,0 +1,103 @@ +From daf4c9fadaf8a49198c53c039bf78980dc251a4b Mon Sep 17 00:00:00 2001 +From: Hans de Goede <hdegoede@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@gmail.com> +Signed-off-by: Hans de Goede <hdegoede@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 + diff --git a/dev-libs/libusbx/libusbx-1.0.16-r2.ebuild b/dev-libs/libusbx/libusbx-1.0.16-r2.ebuild new file mode 100644 index 000000000000..8e821518d676 --- /dev/null +++ b/dev-libs/libusbx/libusbx-1.0.16-r2.ebuild @@ -0,0 +1,64 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-libs/libusbx/libusbx-1.0.16-r2.ebuild,v 1.1 2013/08/05 13:34:08 ssuominen Exp $ + +EAPI=5 +inherit eutils toolchain-funcs + +DESCRIPTION="Userspace access to USB devices" +HOMEPAGE="http://libusbx.sourceforge.net/" +SRC_URI="mirror://sourceforge/${PN}/${P}.tar.bz2" + +LICENSE="LGPL-2.1" +SLOT="1" +KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 -x86-fbsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos" +IUSE="debug doc examples static-libs test udev" + +RDEPEND="!dev-libs/libusb:1 + udev? ( >=virtual/udev-200 )" +DEPEND="${RDEPEND} + doc? ( app-doc/doxygen )" + +DOCS="AUTHORS ChangeLog NEWS PORTING README THANKS TODO" + +src_prepare() { + epatch \ + "${FILESDIR}"/${P}-linux-Use-a-separate-lock-to-serialize-start-stop-vs.patch \ + "${FILESDIR}"/${P}-hotplug-Remove-use-of-pthread_cancel-from-linux_udev.patch +} + +src_configure() { + econf \ + $(use_enable static-libs static) \ + $(use_enable udev) \ + $(use_enable debug debug-log) \ + $(use_enable test tests-build) +} + +src_compile() { + default + + use doc && emake -C doc docs +} + +src_test() { + default + + # noinst_PROGRAMS from tests/Makefile.am + tests/stress || die +} + +src_install() { + default + + gen_usr_ldscript -a usb-1.0 + + if use examples; then + insinto /usr/share/doc/${PF}/examples + doins examples/*.{c,h} + fi + + use doc && dohtml doc/html/* + + prune_libtool_files +} |