Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start-stop-daemon, supervise-daemon: use close_range with musl #645

Merged
merged 4 commits into from
Sep 13, 2023

Conversation

ncopa
Copy link
Contributor

@ncopa ncopa commented Aug 29, 2023

Make sure that we use close_range also with musl libc, using syscall directly.

This fixes a severe performance issue when running openrc under docker where the maxfd may be 1G.

@ncopa
Copy link
Contributor Author

ncopa commented Aug 30, 2023

Maybe we should also set CLOEXEC instead of closing it in start-stop-daemon, similar as it is done in supervise-daemon.

@ncopa
Copy link
Contributor Author

ncopa commented Aug 30, 2023

I refactored it a bit to be less hackish. Also changed start-stop-daemon to use CLOEXEC instead of closing the filedescriptors, similar to what supervise-daemon does.

algitbot pushed a commit to alpinelinux/aports that referenced this pull request Aug 30, 2023
@ncopa ncopa force-pushed the close_range branch 2 times, most recently from a438f14 to 076e0db Compare September 1, 2023 07:34
Use HAVE_CLOSE_RANGE to tell if system provides a close_range(2)
wrapper, which better explains the purpose.

Add a compat inline which returns -1 if close_range is unavailable.
Move logic to set file descriptors to a cloexec_fds_from() function in
misc.c so it can be shared by both supervisor-daemon and
start-stop-daemon, and hide the details behind.
Set file descriptors to CLOEXEC instead of closing them before exec,
similar to what we do in supervise-daemon.

Use the share cloexec_fds_from() helper for this.

closefrom() is no longer used so remove the test.
Add fallback for the close_range syscall wrapper. This is needed for
musl libc, which currently does not have a close_range wrapper.

Also set errno on errors.
bell-sw pushed a commit to bell-sw/alpaquita-aports that referenced this pull request Sep 8, 2023
[ commit 76c4c51f8e4cdd27fbc76ecd2439d01260cadfd4 ]

upstream: OpenRC/openrc#645
@williamh williamh merged commit c4785f1 into OpenRC:master Sep 13, 2023
5 checks passed
@ncopa ncopa deleted the close_range branch September 18, 2023 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants