Page MenuHomeFreeBSD

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

Authored by bapt on Fri, Jan 3, 1:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 16, 2:12 PM
Unknown Object (File)
Thu, Jan 16, 11:17 AM
Unknown Object (File)
Thu, Jan 16, 11:17 AM
Unknown Object (File)
Thu, Jan 16, 11:17 AM
Unknown Object (File)
Thu, Jan 16, 11:17 AM
Unknown Object (File)
Thu, Jan 16, 11:16 AM
Unknown Object (File)
Thu, Jan 16, 11:16 AM
Unknown Object (File)
Thu, Jan 16, 11:16 AM

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 Skipped
Unit
Tests Skipped
Build Status
Buildable 61499
Build 58383: arc lint + arc unit

Event Timeline

bapt requested review of this revision.Fri, Jan 3, 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
176

This doesn't seem like it would work?

192

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

192

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
192

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.Tue, Jan 7, 7:55 AM
bapt added inline comments.
lib/libusb/libusb10_hotplug.c
176

sorry bad rebase

192

bad rebase as well

This revision is now accepted and ready to land.Wed, Jan 8, 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.Thu, Jan 9, 9:13 AM
This revision is now accepted and ready to land.Thu, Jan 16, 2:07 PM