router/serve: restore the cfg(unix) gating the listener refactor dropped - #528
Merged
jevolk merged 1 commit intoAug 3, 2026
Merged
Conversation
`serve/unix.rs` is `#![cfg(unix)]`, and `serve.rs` used to respect that: through v1.5.1 it contained no unix-specific code at all, so the file itself was platform-neutral and the socket work stayed behind the gate. `da92b973 Refactor axum listener setup, fixes matrix-construct#374` moved that work inline without carrying the gate across. `serve.rs` now has an unconditional `use std::os::unix::net::UnixListener`, an unconditional `systemd_listeners()?`, and a `make_log_addrs` whose signature takes `&[UnixListener]`. Both `systemd_listeners` variants are selected on `not(target_os = "linux")`, which includes targets that have no unix sockets. The file no longer compiles off unix. v1.8.2 added `Cow` for the `map_or` inside `make_log_addrs`, which inherits the same problem. This puts the gate back. The unix-only import, the `passed_unix_listeners` data flow, and `make_log_addrs` go behind `#[cfg(unix)]`; both `systemd_listeners` cfgs gain `unix`; and a `#[cfg(not(unix))]` `make_log_addrs` keeps the TCP and configured-path entries, which is all a target without unix sockets can report. Rather than a non-unix `systemd_listeners` stub, the non-unix path skips the call and starts from an empty listener set, since socket activation is unix-only by construction. The unix code path is unchanged: on unix every added cfg selects exactly what was selected before -- `target_os = "linux"` already implies `unix`, and the narrowed second variant still applies to macOS and the BSDs. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
src/router/serve/unix.rsis#![cfg(unix)], andserve.rsused to respectthat. Through v1.5.1 it contained no unix-specific code at all — the socket work
lived entirely inside that gated submodule and
serve.rsitself wasplatform-neutral.
da92b973 Refactor axum listener setup, fixes #374moved that work inlinewithout carrying the gate across.
serve.rsnow has:use std::os::unix::net::UnixListener,systemd_listeners()?,make_log_addrs(…, &passed_unix_listeners), whose signature takes&[UnixListener],systemd_listenersvariants selected onnot(target_os = "linux"),which includes targets that have no unix sockets at all.
The file therefore no longer compiles off unix. v1.8.2 added
Cowfor themap_orinsidemake_log_addrs, which inherits the same problem.This puts the gate back:
passed_unix_listenersdata flow andmake_log_addrsgo behind#[cfg(unix)];systemd_listenerscfgs gainunix;#[cfg(not(unix))]make_log_addrskeeps the TCP and configured-pathentries, which is all a target without unix sockets can report.
Rather than adding a non-unix
systemd_listenersstub, the non-unix path skipsthe call and starts from an empty listener set — socket activation is unix-only
by construction, so there is nothing for a stub to mean.
The unix code path is unchanged. Every added cfg selects on unix exactly what
was selected before:
target_os = "linux"already impliesunix, and thenarrowed second
systemd_listenersvariant still applies to macOS and the BSDs.The narrowing only excludes targets where that variant's return type could not be
constructed anyway.
On verification. CI builds Linux only, where this is a no-op both before and
after, so CI cannot demonstrate the change. It was observed building v1.8.2 for
x86_64-pc-windows-msvc.cargo checkandcargo clippyon the unix path areclean before and after.
Third in the series with #526 and #527.
Checklist
cargo fmtand satisfies clippy andrustc lints; any allowed lint is justified by an obvious reason or a
comment.
are noted in the description above. — none; the unix path is unchanged.
src/core/config/mod.rsdoccomments and the regenerated
tuwunel-example.tomlis committed. — n/adocs/. — n/aand my conduct is in line with the Contributor's Covenant and
Tuwunel's Code of Conduct.