Page MenuHomeFreeBSD

libusb: use eventfd
ClosedPublic

Authored by bapt on May 15 2025, 1:29 PM.
Tags
None
Referenced Files
F120456006: D50360.id155516.diff
Wed, Jun 18, 3:04 AM
Unknown Object (File)
Sat, Jun 14, 10:18 PM
Unknown Object (File)
Sat, Jun 14, 9:37 PM
Unknown Object (File)
Sat, Jun 14, 9:33 PM
Unknown Object (File)
Sat, Jun 14, 8:47 PM
Unknown Object (File)
Wed, Jun 11, 12:48 PM
Unknown Object (File)
Thu, May 29, 5:43 PM
Unknown Object (File)
Wed, May 28, 10:29 AM
Subscribers

Details

Summary

Simplify libusb code by replace pipe(2) inter thread event mecanism
with eventfd(2).

This simplifies the code.

Diff Detail

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

Event Timeline

bapt requested review of this revision.May 15 2025, 1:29 PM

note that it makes android's adb tool working reliably

it does not fix but get stalled less often

It's a good cleanup, even if it doesn't solve the problem.

lib/libusb/libusb10_io.c
190

I wonder if we should be gating this else behind fds[i].revents != 0. It makes sense not to continue at the beginning unconditionally because we need to drop the reference if we had a device, but my concern in this branch is that we could have raced after poll(2) returned and accidentally drained something we shouldn't have.

The question I'm contemplating in particular is: if we were to avoid it here, would we observe a different state above poll(2) when we re-enter this function? e.g., a device appearing. In the worst case scenario, ignoring anything in the pipe here that wasn't at the time of the poll(2) causes a spurious wakeup and we subsequently drain it.

This revision is now accepted and ready to land.May 15 2025, 2:12 PM
This revision was automatically updated to reflect the committed changes.