Skip to content

router/serve: restore the cfg(unix) gating the listener refactor dropped - #528

Merged
jevolk merged 1 commit into
matrix-construct:mainfrom
obodnikov:fix/router-serve-unix-gating
Aug 3, 2026
Merged

router/serve: restore the cfg(unix) gating the listener refactor dropped#528
jevolk merged 1 commit into
matrix-construct:mainfrom
obodnikov:fix/router-serve-unix-gating

Conversation

@obodnikov

Copy link
Copy Markdown
Contributor

What does this PR do?

src/router/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 — the socket work
lived entirely inside that gated submodule and serve.rs itself was
platform-neutral.

da92b973 Refactor axum listener setup, fixes #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()?,
  • make_log_addrs(…, &passed_unix_listeners), whose signature takes
    &[UnixListener],
  • both systemd_listeners variants selected on not(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 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;
  • 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 adding a non-unix systemd_listeners stub, the non-unix path skips
the 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 implies unix, and the
narrowed second systemd_listeners variant 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 check and cargo clippy on the unix path are
clean before and after.

Third in the series with #526 and #527.

Checklist

  • Code is formatted with nightly cargo fmt and satisfies clippy and
    rustc lints; any allowed lint is justified by an obvious reason or a
    comment.
  • Complement compliance changes (new passes or new failures), if any,
    are noted in the description above. — none; the unix path is unchanged.
  • Config option changes were made in src/core/config/mod.rs doc
    comments and the regenerated tuwunel-example.toml is committed. — n/a
  • User-facing changes are reflected in docs/. — n/a
  • I agree that my changes may be licensed under the Apache-2.0 licence
    and my conduct is in line with the Contributor's Covenant and
    Tuwunel's Code of Conduct.

`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>
@jevolk jevolk added bug Something isn't right. build Related to compiling, Rust versions, dependency issues regression Bug resulting from another fix or feature. Only for released code, otherwise use release-blocker. labels Aug 2, 2026
@jevolk
jevolk merged commit f7cef8d into matrix-construct:main Aug 3, 2026
99 of 102 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't right. build Related to compiling, Rust versions, dependency issues regression Bug resulting from another fix or feature. Only for released code, otherwise use release-blocker.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants