Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jun 2019 12:04:54 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r349410 - head/lib/libusb
Message-ID:  <201906261204.x5QC4sjv009715@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201906261204.x5QC4sjv009715>