Page MenuHomeFreeBSD

libsys: fix sleep(3)/usleep(3) cancel behavior
ClosedPublic

Authored by kib on Feb 23 2024, 2:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 17, 12:13 PM
Unknown Object (File)
Tue, May 7, 2:25 AM
Unknown Object (File)
Sun, May 5, 5:08 PM
Unknown Object (File)
Fri, Apr 26, 3:38 AM
Unknown Object (File)
Apr 8 2024, 10:35 AM
Unknown Object (File)
Apr 7 2024, 9:22 PM
Unknown Object (File)
Apr 7 2024, 9:08 AM
Unknown Object (File)
Mar 27 2024, 8:43 AM

Details

Summary
Move functions back to libc/gen sources; they are only versioned from
libc and not libsys.
Access libsys interposing slots using __libsys_interposing_slot()
instead of direct __libsys_interposing array dereference, which cannot
work from libc.

Reported by:    glebius

Diff Detail

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

Event Timeline

kib requested review of this revision.Feb 23 2024, 2:57 PM
This revision is now accepted and ready to land.Feb 23 2024, 5:22 PM
This revision was automatically updated to reflect the committed changes.
jrtc27 added inline comments.
lib/libc/gen/sleep.c
58

Why not just call nanosleep(2) which can access this directly?

lib/libc/gen/sleep.c
58

I think this code just evolved that way. Calling nanosleep() from libc did not work, so it needed explicit interposing. Then for the same reason it needed the interposing call in libsys.
But back into libc, with nanosleep() located in libsys, it should be no longer needed.

Feel free to change, assuming it works.

lib/libc/gen/sleep.c
58

I was wrong, it is more complicated. Originally, the call was to _nanosleep() and not sleep, due to libc namespacing. Right now _nanosleep() in libsys is same as __sys_nanosleep(), i.e. not interposed. So the indirection through the slot is required there.

Or we should change _nanosleep() to be alias for nanosleep() in libsys.