Skip to content

Conversation

@navi-desu
Copy link
Member

No description provided.

Copy link
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. Didn't test it out.

eerrorx("%s: invalid ready '%s'.", applet, optarg);

ready.type = READY_FD;
pipe(ready.pipe);
Copy link
Contributor

Choose a reason for hiding this comment

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

Return value needs checking here, it may fail.

Same with some of the dup2 calls.

Adds two helper functions, and allows scripts to wait until services are
ready before proceeding with it's dependees by setting `ready=fd:<num>`,
where <num> is the file descriptor the daemon should write a new line to.
@navi-desu navi-desu marked this pull request as ready for review February 22, 2025 00:46
@navi-desu navi-desu merged commit c9d634a into master Feb 22, 2025
6 of 8 checks passed
@navi-desu navi-desu deleted the notify branch February 22, 2025 00:47

if (ready.type == READY_FD) {
close(ready.pipe[0]);
dup2(ready.pipe[1], ready.fd);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be checked.

Copy link
Member Author

Choose a reason for hiding this comment

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

those don't really matter at this point. if they fail, the daemon can't write the \n, so the supervisor will already be waiting on ready until openrc-run times out and kill it

the best we can do is check and log, if we exit same thing happens, supervisor will start waiting until timeout and s-s-d won't be doing healthchecks

i'd argue for s-s-d it's better to let the exec go through, since then we have a chance of the daemon writing it's pid file so the timeout can kill it cleanly. for s-d that doesn't matter

Copy link
Contributor

Choose a reason for hiding this comment

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

if they fail, the daemon can't write the \n

Not necessarily. Let's say the ready fd is supposed to be 3 and the dup2 fails. And in the daemon there's code like this:

somefd = open("somefile", ...); // this gets fd 3 since it's available
// ...
write(3, "ready\n", 6); // this now writes into "somefile"

Now you end up with the deamon potentially writing nonsense elsewhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

good point, i'll add the checks then

cloexec_fds_from(3);

if (ready.type == READY_FD)
dup2(ready.pipe[1], ready.fd);
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

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.

3 participants