Skip to content

librc: use dirfd and *at functions.#819

Merged
navi-desu merged 9 commits intomasterfrom
dirfd
Apr 15, 2025
Merged

librc: use dirfd and *at functions.#819
navi-desu merged 9 commits intomasterfrom
dirfd

Conversation

@navi-desu
Copy link
Copy Markdown
Member

@navi-desu navi-desu commented Mar 28, 2025

gives us atomic operations, removes almost all path string allocations, and reduces the number of syscalls

Comment thread src/librc/librc.c Outdated
@navi-desu
Copy link
Copy Markdown
Member Author

i'll fix the ci tomorrow i left a trailing whitespace somewhere

Copy link
Copy Markdown
Contributor

@N-R-K N-R-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a cursory glance. Haven't looked too deeply since it's a pretty large change.

Comment thread src/shared/helpers.h
Comment thread src/librc/librc-depend.c Outdated
@navi-desu navi-desu force-pushed the dirfd branch 2 times, most recently from 2b27eec to 32635b6 Compare March 30, 2025 01:11
@navi-desu navi-desu marked this pull request as ready for review March 30, 2025 01:14
Comment thread src/librc/librc.c Outdated
Comment thread src/librc/librc.c Outdated
Comment thread src/shared/helpers.h Outdated
Comment thread src/librc/librc.c Outdated
Comment thread src/librc/librc-misc.c Outdated
Comment thread src/librc/librc-misc.c Outdated
@navi-desu navi-desu force-pushed the dirfd branch 3 times, most recently from 0c62470 to b6df440 Compare April 4, 2025 00:43
@navi-desu
Copy link
Copy Markdown
Member Author

currently this looks good imo, i'm only unsure about the rc_scripdirfd bits

i'll wait a bit to see if anyone has any opinion, and either merge, or ax those commits and think about that later on...

Copy link
Copy Markdown
Contributor

@N-R-K N-R-K left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly okay, aside from rc_scriptdirfd() and friends.

Comment thread src/librc/librc-depend.c
Comment thread src/librc/librc.c Outdated
Comment thread src/openrc/rc.c Outdated
Comment thread src/librc/librc-depend.c
Comment thread src/librc/librc.c Outdated
Comment thread src/librc/librc.c Outdated
this allows us to do atomic operations in the runtime directories used
by openrc, while at the same time avoiding unnecessary path allocations
and reducing syscalls

the function "lazy loads" the fds by only opening them once when
requested, with O_CLOEXEC set so no cleanup is required
@navi-desu navi-desu force-pushed the dirfd branch 5 times, most recently from 0d9d943 to 482dadc Compare April 14, 2025 23:36
this also fixes the behaviour of rc_service_scheduled_by, returning
a stringlist of service names, instead of the script that is being
scheduled.
we would no longer need to create runtime directories during the
(conditional) dependency update needed check, so we can remove the
checks from there and instead rely on the directory apis
the fd list is only populated with scriptdirs that exist, since some
might not be in use.
@navi-desu navi-desu merged commit e7a1059 into master Apr 15, 2025
10 checks passed
@navi-desu navi-desu deleted the dirfd branch April 15, 2025 00:32
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.

2 participants