diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-06-14 11:51:38 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-06-14 15:47:50 +0200 |
commit | 1cf2969bc8e696118bb639c787d68fc324690f88 (patch) | |
tree | 307b79406a872311dbbcad8cfed14afdd69bd4dc | |
parent | f9ef58d8c4fea65152938c2bc7b8bff60d4a14a6 (diff) | |
download | libusb-1cf2969bc8e696118bb639c787d68fc324690f88.tar.gz |
linux_udev: Join the hotplug-event-thread when we stop event monitoring
To ensure that it is stopped before we continue (and if later libusb
gets re-initialized start another thread).
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | libusb/os/linux_udev.c | 11 | ||||
-rw-r--r-- | libusb/version_nano.h | 2 |
2 files changed, 7 insertions, 6 deletions
diff --git a/libusb/os/linux_udev.c b/libusb/os/linux_udev.c index 29c949a..abecdd4 100644 --- a/libusb/os/linux_udev.c +++ b/libusb/os/linux_udev.c @@ -119,16 +119,17 @@ int linux_udev_stop_event_monitor(void) assert(udev_monitor != NULL); assert(udev_monitor_fd != -1); - /* Cancel the event thread. This is the only way to garauntee the thread - exits since closing the monitor fd won't necessarily cause poll - to return. */ - pthread_cancel(linux_event_thread); - /* Release the udev monitor */ udev_monitor_unref(udev_monitor); udev_monitor = NULL; udev_monitor_fd = -1; + /* Cancel the event thread. This is the only way to garauntee the + thread exits since closing the monitor fd won't necessarily cause + poll to return. */ + pthread_cancel(linux_event_thread); + pthread_join(linux_event_thread, NULL); + /* Clean up the udev context */ udev_unref(udev_ctx); udev_ctx = NULL; diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 6447594..3d5965f 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10737 +#define LIBUSB_NANO 10738 |