Page MenuHomeFreeBSD

libusb: hotplug, use events instead of a timer when possible
ClosedPublic

Authored by bapt on Jan 3 2025, 1:34 PM.
Tags
None
Referenced Files
F109879941: D48300.id148968.diff
Mon, Feb 10, 4:56 PM
F109811009: D48300.id148763.diff
Sun, Feb 9, 8:25 PM
Unknown Object (File)
Thu, Feb 6, 4:13 PM
Unknown Object (File)
Wed, Feb 5, 11:17 PM
Unknown Object (File)
Tue, Feb 4, 7:46 PM
Unknown Object (File)
Tue, Feb 4, 2:57 AM
Unknown Object (File)
Sun, Feb 2, 10:30 PM
Unknown Object (File)
Sun, Feb 2, 5:30 PM

Details

Summary

Try to fetch events from nlsysevent or devd to determine when
to scan the usb bus for devices addition or removal.
if none are available fallback on the regular timer based (4s)
scanner

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bapt requested review of this revision.Jan 3 2025, 1:34 PM
lib/libusb/libusb10_hotplug.c
57

Hi @bapt,

According to devd(8) '/var/run/devd.pipe' is deprecated in favor for '/var/run/devd.seqpacket.pipe', any reason for still using it here ?

Looks fine in principle

lib/libusb/libusb10_hotplug.c
249

This doesn't seem like it would work?

265

IMO "ignore any error" should just be a (void) cast for the return vaule, but I don't feel strongly about it.

265

Where is timeout coming from here? With this and the above, kinda seems like something went wrong with the patch.

lib/libusb/libusb10_hotplug.c
265

Yeah not a huge issue but I agree (void)poll(...) is both a programmer-readable and machine-readable way to indicate that errors are intentionally ignored.

fix bad rebase
switch from sock_stream to sock_seqpacket for devd's pipe

bapt marked 4 inline comments as done.Jan 7 2025, 7:55 AM
bapt added inline comments.
lib/libusb/libusb10_hotplug.c
249

sorry bad rebase

265

bad rebase as well

This revision is now accepted and ready to land.Jan 8 2025, 8:30 PM
bapt marked an inline comment as done.

actually read the informations bassed in the sockets to avoid poll looping forever
on libusb_exit close the sockets if any to provide immediate shutdown on the hotplug thread.

fallback on the timer based method when something goes wrong

This revision now requires review to proceed.Jan 9 2025, 9:13 AM
This revision is now accepted and ready to land.Thu, Jan 16, 2:07 PM