Skip to content

jobserver fd_check: Allow sockets.#117

Open
xim wants to merge 2 commits into
rust-lang:mainfrom
xim:allow-socket-fds
Open

jobserver fd_check: Allow sockets.#117
xim wants to merge 2 commits into
rust-lang:mainfrom
xim:allow-socket-fds

Conversation

@xim

@xim xim commented Nov 17, 2025

Copy link
Copy Markdown

I agree with the creator of issue #6 that jobserver fds should be allowed to be sockets as well as pipes. A project I'm working on uses a jobserver implemented over Unix domain sockets.

@xim

xim commented Nov 17, 2025

Copy link
Copy Markdown
Author

Can add some details ; I already have a piece of software running that creates a token pool across all builds on the local machine using an abstract unix domain socket. It works well with GNU Make, Ninja and gcc.

@xim

xim commented Dec 4, 2025

Copy link
Copy Markdown
Author

I'm more than willing to contribute, and to consider alternative approaches.

@NobodyXu NobodyXu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not a maintainer of jobserver though I did have some contributions and subscribe to updates to jobserver closely and is a maintainer of cc, which use jobserver, so take my comment with a grain of salt.

And I'm not sure if I should merge the PR here on behalf of the maintainer, so probably not unless nobody has time to review it

Comment thread src/error.rs Outdated
FromEnvErrorInner::CannotOpenFd(..) => FromEnvErrorKind::CannotOpenFd,
FromEnvErrorInner::NegativeFd(..) => FromEnvErrorKind::NegativeFd,
FromEnvErrorInner::NotAPipe(..) => FromEnvErrorKind::NotAPipe,
FromEnvErrorInner::NotAPipeOrSocket(..) => FromEnvErrorKind::NotAPipeOrSocket,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would probably be an undesired breaking change, don't think we can rename this enum variant which is unfortunate

Could add a NotASocket

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I checked all uses in cargo/rust, this value was never explicitly referenced.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is better to avoid MSRV bump. I would suggest adding new variant and leave the old one there. We already have #[non_exhaustive] so should be fine adding new variants.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Kept the old public variant and marked it as deprecated

Comment thread src/unix.rs Outdated
@xim xim force-pushed the allow-socket-fds branch 2 times, most recently from 4e4f256 to e0de330 Compare June 15, 2026 09:48
Comment thread src/unix.rs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it possible we have tests for the new behavior including successful paths and failing paths?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sure!

Comment thread src/error.rs Outdated
FromEnvErrorInner::CannotOpenFd(..) => FromEnvErrorKind::CannotOpenFd,
FromEnvErrorInner::NegativeFd(..) => FromEnvErrorKind::NegativeFd,
FromEnvErrorInner::NotAPipe(..) => FromEnvErrorKind::NotAPipe,
FromEnvErrorInner::NotAPipeOrSocket(..) => FromEnvErrorKind::NotAPipeOrSocket,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It is better to avoid MSRV bump. I would suggest adding new variant and leave the old one there. We already have #[non_exhaustive] so should be fine adding new variants.

@xim xim force-pushed the allow-socket-fds branch from e0de330 to d642c53 Compare June 18, 2026 10:41

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the update. Would you mind rebasing onto master so the CI should pass?

xim and others added 2 commits June 19, 2026 11:24
Any fd with compatible semantics can be used for jobserver tokens, not
just pipes. Multiple jobserver implementations use other fd types
already. Other client implementations don't require pipes either, like
those in `make` and `ninja`.

Actually fixes issue rust-lang#6

Co-Authored-By: CertainLach <6235312+CertainLach@users.noreply.github.com>
Pipes, sockets and character devices are supported.

Regular files are not supported.

Additionally, check_pipe=false skips the type check.
@xim xim force-pushed the allow-socket-fds branch from 3eab1b8 to 537dc14 Compare June 19, 2026 09:24
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