svn commit: r349410 - head/lib/libusb
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Jun 26 12:04:55 UTC 2019
Author: hselasky
Date: Wed Jun 26 12:04:54 2019
New Revision: 349410
URL: https://svnweb.freebsd.org/changeset/base/349410
Log:
Only call libusb_hotplug_enumerate() once from libusb_hotplug_register_callback().
Else when registering multiple filters the same USB device may appear twice in
the list.
MFC after: 3 days
Sponsored by: Mellanox Technologies
Modified:
head/lib/libusb/libusb10_hotplug.c
Modified: head/lib/libusb/libusb10_hotplug.c
==============================================================================
--- head/lib/libusb/libusb10_hotplug.c Wed Jun 26 11:28:08 2019 (r349409)
+++ head/lib/libusb/libusb10_hotplug.c Wed Jun 26 12:04:54 2019 (r349410)
@@ -1,6 +1,6 @@
/* $FreeBSD$ */
/*-
- * Copyright (c) 2016 Hans Petter Selasky. All rights reserved.
+ * Copyright (c) 2016-2019 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -200,6 +200,8 @@ int libusb_hotplug_register_callback(libusb_context *c
HOTPLUG_LOCK(ctx);
if (ctx->hotplug_handler == NO_THREAD) {
+ libusb_hotplug_enumerate(ctx, &ctx->hotplug_devs);
+
if (pthread_create(&ctx->hotplug_handler, NULL,
&libusb_hotplug_scan, ctx) != 0)
ctx->hotplug_handler = NO_THREAD;
@@ -210,8 +212,6 @@ int libusb_hotplug_register_callback(libusb_context *c
handle->devclass = dev_class;
handle->fn = cb_fn;
handle->user_data = user_data;
-
- libusb_hotplug_enumerate(ctx, &ctx->hotplug_devs);
if (flags & LIBUSB_HOTPLUG_ENUMERATE) {
TAILQ_FOREACH(adev, &ctx->hotplug_devs, hotplug_entry) {
More information about the svn-src-head
mailing list