This server 2 purposes: 1) We use lazy free-ing of the callback structure, for it to be actually free-ed usbi_hotplug_match() needs to be called. This ensures this actually happens (rather then waiting for a hotplug event to arrive, and not freeing the callback as long as no such event arrives).
2) It causes libusb_handle_events to return to its caller on a call to libusb_hotplug_deregister_callback, which is very useful for apps which use a thread to do their apps (hotplug) event handling, otherwise that thread will hang when the app tries to stop until some event happens. Signed-off-by: Hans de Goede <hdego...@redhat.com> --- libusb/hotplug.c | 8 ++++++++ libusb/version_nano.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libusb/hotplug.c b/libusb/hotplug.c index 7d14192..28c0f2e 100644 --- a/libusb/hotplug.c +++ b/libusb/hotplug.c @@ -270,6 +270,8 @@ void API_EXPORTED libusb_hotplug_deregister_callback (struct libusb_context *ctx libusb_hotplug_callback_handle handle) { struct libusb_hotplug_callback *hotplug_cb; + libusb_hotplug_message message; + ssize_t ret; /* check for hotplug support */ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) { @@ -287,6 +289,12 @@ void API_EXPORTED libusb_hotplug_deregister_callback (struct libusb_context *ctx } } usbi_mutex_unlock(&ctx->hotplug_cbs_lock); + + memset(&message, 0, sizeof(message)); + ret = usbi_write(ctx->hotplug_pipe[1], &message, sizeof(message)); + if (sizeof(message) != ret) { + usbi_err(ctx, "error writing hotplug message"); + } } void usbi_hotplug_deregister_all(struct libusb_context *ctx) { diff --git a/libusb/version_nano.h b/libusb/version_nano.h index fc87a0d..1988fdb 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10769 +#define LIBUSB_NANO 10770 -- 1.8.3.1 ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ libusbx-devel mailing list libusbx-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libusbx-devel