From nobody Thu May 08 18:20:49 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 4ZtgRj6jGDz5vR3m; Thu, 08 May 2025 18:20:49 +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 4ZtgRj52r4z3tGb; Thu, 08 May 2025 18:20:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746728449; 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=QmfKL6TetTypud2e7g0WEroem9WEDekvmj7neBY1YCk=; b=kQMaaM3QI+SZEzWh/EKDMs1C4qbj5NDG7MAQ+O9xE+JKwALsGNhG4+3+xSNFoih0NWIZmh b6q/jXXOa4BX87B1DVV59DGTqIqQJ2USVj9VMcG9S4qqpw2/PZhP3vBXB7JhJ7kNy2bGUF J+7e9XKCOJRTlh2nS93lDv0WK5LsnXKCsXHacRV4lyzkfV6qkWJv9Rp1YUGl8cYg0KMJRX blHJ2wwWMqimlcPx2djy8Feoe44pxXdZymAuIfMGIBfPX8Wy9ccwrIfC/XQvkB/Zc5KfyZ N+2K9OsWkfyMGpsVAQuA5kStif8nbY/kM/S0t2IRUlL/3HwB7fBB69ctZpf3QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1746728449; 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=QmfKL6TetTypud2e7g0WEroem9WEDekvmj7neBY1YCk=; b=m0kZ5A/j5o54lXkjEvJZYJgeEyeVcrosZ7g5Zv/0Dk09rwnUD89ZRXs6TNf5rEvy4/Ff4p S94wyIx/eTNVcujHQRGTjRq1oClKuIwXMWL1pn8v3N9TjYCnX5ZuiF8W2K+xxHhj7yvcSV Q6vIeuMP+ztOLbx/iWEetGb7ulbhzhyyOXm3XcEOv8fggPIzEm/e2cbjYO+3mqfRqU0GT1 jOE0zC8Fwx432UjUN8fxA9vdqLJ+8XeV3zDJmZUkMRcpGKMkuVAtpATpWsSFYLXxZ1RqpO w4pDVy9T1EUsTbIRJGYyx8oWcTzF1F0M3rjfrls+lfnFHig7f8/xbUvaLXFN1Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1746728449; a=rsa-sha256; cv=none; b=yMEcOO2mN7PCCc6j1Rvu7hW9fKdsGxUaja4jYzBW/3OrgCl42K68p/72A0liWLx53oy/2t 0sllNEwlTcrAhse+Ja+Eeqwvyrn7Tr2NnEYszLayRX/vfwJxgMImRSJKu2NQLdNJS1xe3r U3tjEpX0a4pPwNaTCtMhL339tORPPnFMWN9QeVyTFJhubhR9bg+EDrTv4FaKIdYGDgvjOr x1bPE+afVWKOeTq4GdmTwNDpYn4V7829M6qVpkEKubC/x5ck/Ykg1PvEmeAq9LE70gfRds HoC+3I97s0NrnDI8p5/PjvnIjqmdjosF9Dyg19s2rpOrAvJBMcVQltGWyGW1ww== 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 4ZtgRj4dsHzB0d; Thu, 08 May 2025 18:20:49 +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 548IKnjA028476; Thu, 8 May 2025 18:20:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 548IKniq028473; Thu, 8 May 2025 18:20:49 GMT (envelope-from git) Date: Thu, 8 May 2025 18:20:49 GMT Message-Id: <202505081820.548IKniq028473@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: d28526591803 - main - 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/main X-Git-Reftype: branch X-Git-Commit: d2852659180307475a8376ce86aa587cccbb10bf Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=d2852659180307475a8376ce86aa587cccbb10bf commit d2852659180307475a8376ce86aa587cccbb10bf Author: SHENGYI HUNG AuthorDate: 2025-05-05 17:52:45 +0000 Commit: Ed Maste CommitDate: 2025-05-08 18:20:21 +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 --- 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 b7573bf916ec..1e8037da1bd4 100644 --- a/lib/libusb/libusb10_hotplug.c +++ b/lib/libusb/libusb10_hotplug.c @@ -407,6 +407,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); }