Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 6 Aug 2025 14:20:30 GMT
From:      ShengYi Hung <aokblast@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b0d5c1cfda76 - main - libusb: implement libusb_pollfds_handle_timeouts
Message-ID:  <202508061420.576EKU4E009576@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by aokblast:

URL: https://cgit.FreeBSD.org/src/commit/?id=b0d5c1cfda7696e62fa0256b5aab0e218ab98c45

commit b0d5c1cfda7696e62fa0256b5aab0e218ab98c45
Author:     ShengYi Hung <aokblast@FreeBSD.org>
AuthorDate: 2025-08-05 15:25:31 +0000
Commit:     ShengYi Hung <aokblast@FreeBSD.org>
CommitDate: 2025-08-06 14:05:40 +0000

    libusb: implement libusb_pollfds_handle_timeouts
    
    This function tells applications who maintain the pollfds themselves if
    they should handle the timeout for each xfer themselves. In FreeBSD, the
    timeout for each xfer is handled by kernel and doesn't need a special timer to
    do so. Therefore, we return 1 to indicate that it is handled by libusb
    internally.
    
    Approved by:    lwhsu (mentor), markj (mentor)
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D51742
---
 lib/libusb/libusb.3      | 8 ++++++++
 lib/libusb/libusb.h      | 1 +
 lib/libusb/libusb10_io.c | 6 ++++++
 3 files changed, 15 insertions(+)

diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index 9dc752f0fd7b..3093737c05d7 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -734,6 +734,14 @@ another thread is already doing so.
 Must be called with the event lock held.
 .Pp
 .Ft int
+.Fn libusb_pollfds_handle_timeouts "libusb_context *ctx"
+This function determines whether applications maintaining libusb events using
+.Fn libusb_get_pollfds
+are responsible for handling timeout events themselves.
+Returns 1 if libusb handles the timeout internally, 0 if the application
+needs to set a dedicated timer to handle it.
+.Pp
+.Ft int
 .Fn libusb_get_next_timeout "libusb_context *ctx" "struct timeval *tv"
 Determine the next internal timeout that libusb needs to handle.
 Returns 0
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index 85e24bc68474..d8a3e4b62995 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -587,6 +587,7 @@ int	libusb_handle_events_completed(libusb_context * ctx, int *completed);
 int	libusb_handle_events_timeout(libusb_context * ctx, struct timeval *tv);
 int	libusb_handle_events(libusb_context * ctx);
 int	libusb_handle_events_locked(libusb_context * ctx, struct timeval *tv);
+int	libusb_pollfds_handle_timeouts(libusb_context *ctx);
 int	libusb_get_next_timeout(libusb_context * ctx, struct timeval *tv);
 void	libusb_set_pollfd_notifiers(libusb_context * ctx, libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb, void *user_data);
 const struct libusb_pollfd **libusb_get_pollfds(libusb_context *ctx);
diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c
index c99586ff650d..2047712e9e39 100644
--- a/lib/libusb/libusb10_io.c
+++ b/lib/libusb/libusb10_io.c
@@ -422,6 +422,12 @@ libusb_get_next_timeout(libusb_context *ctx, struct timeval *tv)
 	return (0);
 }
 
+int
+libusb_pollfds_handle_timeouts(libusb_context *ctx)
+{
+	return (1);
+}
+
 void
 libusb_set_pollfd_notifiers(libusb_context *ctx,
     libusb_pollfd_added_cb added_cb, libusb_pollfd_removed_cb removed_cb,



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