From nobody Wed May 14 14:24:12 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZyFvw2lZCz5wmCP; Wed, 14 May 2025 14:24:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZyFvw27qxz3w11; Wed, 14 May 2025 14:24:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747232652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lwhk2L2AGWvtRBZNWDGGsc2o64zjrdKbojm5QAtiC3A=; b=rF6kPLqUnlIZj8nh6T9tmWilLGbwPIjyvCPJp5uyzW+g7nV2Ga5DH47BMga07rlYtDg+/q TTGGuab/T0lOYRlBXVfTYHSaaE4tCLYyht8V0xbXPlkiq4NV+UsMWEXJgmdNxRTfHF3QOP mZyb0bLpM3wTTkvrW7X0Tvk/lGx5c+bat9EYc1f10OKef/6prJiqJ/+zknLj8nLdan9unC qUmeth3SP1Eo5QMhU2LqEDd+g5AC0nIOQ1pmLZAs7+uUByUPOeJF0n2WF7YXi0MgRLE03L Ga9nXVoISU8P6BhdQplUkhFnkJgdd0bMzE9zeGezCXzwpj+o7TmgwhN0izFlVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1747232652; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=lwhk2L2AGWvtRBZNWDGGsc2o64zjrdKbojm5QAtiC3A=; b=BsYqrjCV9GNnQqlPLmNEXWIUB6UTpGvv0kooX6ZqHAA5XbOee+2WEKbPmDFxuPPHFJnh9t 1NAhTEeZNR6vq1b7a4efRvwBo7RRU+4z7WbDV9bm7Z2svb0jfNv5E6nWhWy0jBs5PYENmn zKOaceVS7ijiGQ/KyJNIzHB3YtNFUIzs0x/dchvC9NAkhlJ0N0L84WIqMLF0u7O6mszx1X KMhnY/oDBIhrjEWXjT/HyGmoBy+jYHtlEh/ibxE9YPjsoA5uowHqKOMXZ2e0w78oTYpvIY xwUgUP2KHM/u/jrtbsXRlvebC/2tYXzn2ggI55ltwZnSb0IzID02vC2wFKfAFg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1747232652; a=rsa-sha256; cv=none; b=fG86X0Qk0i64qlyJuxyfU22OdARwYn1bzQ2RxWDnOk8m8NQpIFBdwKm6ospUtny2P89Cdb 2FkEfAuuSbP/9JPfn4Fmor4/n5Ea1Yrm5br+w7SrnwWdsD7L6vxJDZyjI4EHQ34dcl/I0z 3fT008XwnWwOLCHnO0ua6mR7tA++Bt1u92doTjhSyQXn0JzbUB5Vp6z0MGInoO7/NaphKN s8zaqSjz+fG9hlkDLHIqx5s23S8HQ17+yd8oKbHHVpr4TG7vudpgJSVyufans8ieJU3Hjb 0XmeTRQHjG6HgL1xf8me/zDdMYQLsOJhcP2yBiUm2E2zNUSmLR/B27qgEJ+NuQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZyFvw1LvZzc8s; Wed, 14 May 2025 14:24:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 54EEOCRo060509; Wed, 14 May 2025 14:24:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 54EEOCau060506; Wed, 14 May 2025 14:24:12 GMT (envelope-from git) Date: Wed, 14 May 2025 14:24:12 GMT Message-Id: <202505141424.54EEOCau060506@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 641bb44d8538 - stable/14 - libusb: Emit event after deregistering hotplug handler List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 641bb44d8538c66446aea556baa22bbf5bd14255 Auto-Submitted: auto-generated The branch stable/14 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=641bb44d8538c66446aea556baa22bbf5bd14255 commit 641bb44d8538c66446aea556baa22bbf5bd14255 Author: SHENGYI HUNG AuthorDate: 2025-05-05 17:52:45 +0000 Commit: Ed Maste CommitDate: 2025-05-14 14:23:38 +0000 libusb: Emit event after deregistering hotplug handler The original implementation did not emit an event when a hotplug handler was deregistered. This omission causes issues for programs that follow the best practices recommended by libusb—particularly those that use `libusb_hotplug_register_callback()` or similar functions in a loop while managing hotplug handlers dynamically. Without emitting an event after deregistration, these programs can become stuck waiting indefinitely for an event that will never come, as the condition to break out of the wait loop is never satisfied. See: https://github.com/libusb/libusb/blob/6c0ae1ab456da49e7805115e77ce0428ace4ea41/libusb/hotplug.c#L459 Reviewed by: bapt Sponsored By: FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D50170 (cherry picked from commit d2852659180307475a8376ce86aa587cccbb10bf) --- lib/libusb/libusb10_hotplug.c | 1 + lib/libusb/libusb10_io.c | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/libusb/libusb10_hotplug.c b/lib/libusb/libusb10_hotplug.c index 98903686f76b..87490d3a76c7 100644 --- a/lib/libusb/libusb10_hotplug.c +++ b/lib/libusb/libusb10_hotplug.c @@ -246,6 +246,7 @@ void libusb_hotplug_deregister_callback(libusb_context *ctx, HOTPLUG_LOCK(ctx); TAILQ_REMOVE(&ctx->hotplug_cbh, handle, entry); + libusb_interrupt_event_handler(ctx); HOTPLUG_UNLOCK(ctx); free(handle); diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c index 59bac60c4672..2790142486ba 100644 --- a/lib/libusb/libusb10_io.c +++ b/lib/libusb/libusb10_io.c @@ -231,6 +231,7 @@ do_done: /* Wakeup other waiters */ pthread_cond_broadcast(&ctx->ctx_cond); + DPRINTF(ctx, LIBUSB_DEBUG_FUNCTION, "libusb10_handle_events_sub complete"); return (err); }