Skip to content

docs(lifecycle): repair every file.rs:NNN citation in the module LIFECYCLE documents - #1366

Merged
FlorentinDUBOIS merged 1 commit into
mainfrom
docs/lifecycle-citation-repair
Sep 20, 2026
Merged

FlorentinDUBOIS merged 1 commit into
mainfrom
docs/lifecycle-citation-repair

Conversation

@FlorentinDUBOIS

@FlorentinDUBOIS FlorentinDUBOIS commented Sep 20, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #1335. Repairs every file.rs:NNN citation in the five non-empty module LIFECYCLE.md files.
doc/ and the committed CI resolver are a separate change.

What was measured

517 citations, not the 393 the issue implies. The issue's counting pattern
[A-Za-z_/.-]+\.rs:[0-9]+ has no digit in its character class, so it silently skips every
citation naming a file with a digit — h1.rs:NNN, h2.rs:NNN. On mux/LIFECYCLE.md that is 78
occurrences counted where the truth is 201. Use [A-Za-z0-9_/.-]+\.rs:[0-9]+(-[0-9]+)?.

file citations kept renumbered → symbol anchor
bin/src/command/LIFECYCLE.md 53 8 survive
lib/src/protocol/kawa_h1/LIFECYCLE.md 58 15 survive
lib/src/protocol/mux/LIFECYCLE.md 201 117 survive
lib/src/protocol/proxy_protocol/LIFECYCLE.md 42 19 survive
lib/src/protocol/udp/LIFECYCLE.md 163 46 survive
total 517 35 already right 170 renumbered 312 → symbol

tcp_preread/LIFECYCLE.md has zero citations because it was written symbol-first. Its preamble is
the precedent this repair follows; it is untouched.

Why a mechanical sweep would not have worked

A resolver over the branch point reports TOTAL=517 OK=498 BLANK=19. It passes 498 of 517 while
171 of the 207 survivors still needed renumbering. A line-based check cannot see a citation that
drifted onto a different non-blank line, which is the dominant failure mode.

So the method was per-citation: the prose line, the content at the cited line, and an independent
candidate computed by finding the commit that introduced the citation (git log --reverse -S) and
mapping the source line to HEAD with difflib on the two blobs. Where HEAD already matched the prose
the citation was kept (the mapping is then a false positive — this fired on expect.rs:118). Where
the introducing commit matched nothing the prose describes, the citation was wrong the day it was
written and was re-derived by grep -n.

312 citations became symbol anchors per option 3 of #1335 — ExpectProxyProtocol::readable
rather than expect.rs:118. A symbol cannot drift. Line numbers survive only where the prose means a
specific branch or statement inside an item. Methods are qualified Type::method so they stay
greppable; ambiguous basenames are repo-root-relative.

Final state: TOTAL=205 OK=205 MISSING=0 PAST_EOF=0 BLANK=0.

Independently verified

A separate agent re-derived this rather than reviewing it: 379 file-reference sites extracted, 0
symbol anchors naming a symbol absent from the file they name (17 automated flags all cleared
manually as pairing-heuristic artefacts), 0 wrong in a 48-item semantic sample weighted toward
mux, 0 wrong in 64 sampled numeric anchors, and the 517/207/310 totals and the resolver numbers
reproduced exactly. It confirmed no prose claim changed meaning.

Two re-anchorings were judgement calls and both check out: Server::run never existed — fn run is
at server.rs:529 inside impl CommandHub — and upgrade_main is at bin/src/command/upgrade.rs:330,
absent from bin/src/upgrade.rs.

Six stale prose claims found — anchored, not rewritten

Repairing a citation is not licence to rewrite the claim it carries. Each of these is anchored
correctly and left for its own change:

  • mux/LIFECYCLE.md §4.1, §5.4, §8.2 list six sites that "perform self.streams.remove(...)
    inline instead of going through remove_dead_stream". All six now call the helper; the only
    streams.remove( in 9434-line h2.rs is inside remove_dead_stream itself.
  • kawa_h1 §4 names ListenerAnswers / ClusterAnswers; neither exists repo-wide. They were
    flattened into HttpAnswers { cluster_answers, listener_answers, fallback }.
  • kawa_h1 §3.1 describes two CL.TE reject conditions; there are three — a
    te_all_suffix_chunked literal-suffix check was added, and the doc also misstates the second.
  • kawa_h1 §1.3/§4 says DefaultAnswer has 8 variants; mod.rs declares 14.
  • mux/LIFECYCLE.md:219 says Linked(Token) is "cleared by Context::unlink_stream".
    unlink_stream only pattern-matches .state, removes the reverse-index entry and returns the
    token — it never assigns .state. The callers do (h2.rs:6489).
  • the udp diagram cited FlowPhase at mod.rs:42/43/44; FlowPhase has only ever lived in
    flow.rs, and mod.rs:42 is pub type FlowId = usize;.

Stale citations found outside this change's scope

Routed to the doc/ and resolver work, not touched here: mux/h2.rs:3212 carries a stale citation
in a source comment; bin/README.md:25 and command/src/channel.rs's module doc cite
command/src/state.rs:1613, 1630 when write_requests_to_file is at state.rs:2877; and
channel.rs:71 is cited for max_buffer_size but is an error-enum variant.

Validation

cargo +1.93.1 build --all-features → 0. The diff is six files: the five LIFECYCLE.md plus
CHANGELOG.md. git diff --name-only | grep -v '\.md$' is empty — no source file changed. doc/ is
untouched.

The CHANGELOG entry follows the existing convention: three docs(...) entries already sit under
[Unreleased] → ### 🐛 Fixed.

A line anchor can be correct and still break — two were fixed by naming the construct

udp/LIFECYCLE.md cited socket.rs:1326-1330 (the udp_connect doc comment) and socket.rs:1357-1364
(the bind / connect pair). Both were correct against origin/main.

PR #1364 moves udp_connect from 1333 to 1346 — a uniform +13 — after which socket.rs:1326 is
local.is_ipv6(), and socket.rs:1357 is );. Both land on non-blank lines, so a resolver accepts
them: neither branch fails its own run, and the defect exists only in the merged tree.

They are now anchored by name — "the bind / connect pair in udp_connect", "the udp_connect doc
comment" — which keeps the precision the prose earned without the drift, and makes the two branches
order-independent rather than coupled.

FlorentinDUBOIS added a commit that referenced this pull request Sep 20, 2026
… them

A worker upgrade hands the retiring worker's listening sockets to its
replacement over SCM_RIGHTS. The replacement discarded all of them, on
all four protocols.

Server::new applied the initial state -- which generate_requests builds
as one AddXxxListener immediately followed by one ActivateListener per
active listener -- before it called receive_listeners(). scm_listeners
was therefore still None for the whole initial state, so every
ActivateListener took the server_bind / udp_bind branch and the listener
came up active on a socket it had bound itself. That bind succeeds only
because both helpers set SO_REUSEPORT, which is also why this never
surfaced as an outage: the address kept being served throughout.

The inherited descriptors arrived immediately afterwards, and
UpgradeWorkerTask then scattered generate_activate_requests() to the new
worker. Each repeat pulled its descriptor out of the SCM table --
Listeners::get_http and friends remove the entry as they hand it over --
wrapped it in an owning MioTcpListener / MioUdpSocket, and handed it to
an activate() that returns on its `if self.active` guard before it can
consume it. The wrapper dropped and the descriptor closed, once per
listener per upgrade: the accept backlog for TCP/HTTP/HTTPS, so a
connection that had completed its handshake against the old socket got
an RST instead of being served, and the receive buffer for UDP.

Three changes, one per place a descriptor could be lost.

Server::new receives the SCM listeners before it applies the initial
state, so the first ActivateListener adopts the inherited descriptor and
the later repeats find nothing left to discard. No socket is replaced
under a live listener: at that point the listener was created by the
AddXxxListener on the line above and holds no socket at all. The
relocated call is the same blocking read as before, only earlier -- the
sole production caller of fork_main_into_worker, launch_new_worker,
always passes Some(listeners) and always sends a manifest, so a fresh
start receives an empty one immediately and every listener binds its own
socket exactly as it always did.

Ownership is settled before the descriptor leaves the table rather than
after. Each arm of notify_activate_listener asks the proxy
inherited_socket_fate(&address), which answers one of three things.
Adopted -- a listener is there and not active -- takes it. Refused -- a
listener is there and already active on a socket of its own -- takes it
and closes it deliberately, with a warn naming the address: activate()
short-circuits so it could never be adopted, and keeping it would leave
the retiring worker's socket in that address's SO_REUSEPORT group with
no event loop behind it, taking a share of connections nothing accepts
(inferred from SO_REUSEPORT semantics, not measured). Unclaimed -- no
listener at the address -- keeps it, because an AddListener plus
ActivateListener can still adopt it; that is how an upgrade whose
initial state carries the listeners inactive works, so closing leftovers
at the end of startup would destroy the case this commit fixes. No point
during startup makes a leftover provably unclaimable, so retention stays
open-ended and Server::new reports what it kept: info when the address
has a listener awaiting activation, warn when it has none at all.

A third copy lived on the registration-error path. activate() moved the
socket into a local to register it and propagated a Registry::register
failure straight from there, so the `?` dropped the local and closed a
descriptor Listeners::get_* had already removed. register answers EEXIST
for a descriptor already registered on the same epoll instance, which is
what notify_deactivate_listener leaves behind when its deregister only
logs. All four activate() implementations now park the socket on the
listener before propagating the error and reuse a parked socket on the
next attempt instead of binding a second one; active stays false
throughout, so nothing observes a half-activated listener.

Listeners::get_udp gains the removal post-conditions its three siblings
already assert.

doc/upgrade_e2e_tests.md stated the old ordering as the root cause of
its own scenarios, lib/src/protocol/udp/LIFECYCLE.md claimed the
re-exec'd worker adopts the passed fd, and the comment in
e2e/src/sozu/worker.rs justified its deactivate-then-activate sequence
by the defect; all three are corrected. The citations this commit moves
are re-anchored: the ones in the module LIFECYCLE.md become symbol
anchors, following the convention PR #1366 established, and the rest are
updated only where the cited line could be relocated by content.

Closes #1342

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the docs/lifecycle-citation-repair branch from e3b88c5 to ce5266f Compare September 20, 2026 12:04
FlorentinDUBOIS added a commit that referenced this pull request Sep 20, 2026
… them

A worker upgrade hands the retiring worker's listening sockets to its
replacement over SCM_RIGHTS. The replacement discarded all of them, on
all four protocols.

Server::new applied the initial state -- which generate_requests builds
as one AddXxxListener immediately followed by one ActivateListener per
active listener -- before it called receive_listeners(). scm_listeners
was therefore still None for the whole initial state, so every
ActivateListener took the server_bind / udp_bind branch and the listener
came up active on a socket it had bound itself. That bind succeeds only
because both helpers set SO_REUSEPORT, which is also why this never
surfaced as an outage: the address kept being served throughout.

The inherited descriptors arrived immediately afterwards, and
UpgradeWorkerTask then scattered generate_activate_requests() to the new
worker. Each repeat pulled its descriptor out of the SCM table --
Listeners::get_http and friends remove the entry as they hand it over --
wrapped it in an owning MioTcpListener / MioUdpSocket, and handed it to
an activate() that returns on its `if self.active` guard before it can
consume it. The wrapper dropped and the descriptor closed, once per
listener per upgrade: the accept backlog for TCP/HTTP/HTTPS, so a
connection that had completed its handshake against the old socket got
an RST instead of being served, and the receive buffer for UDP.

Three changes, one per place a descriptor could be lost.

Server::new receives the SCM listeners before it applies the initial
state, so the first ActivateListener adopts the inherited descriptor and
the later repeats find nothing left to discard. No socket is replaced
under a live listener: at that point the listener was created by the
AddXxxListener on the line above and holds no socket at all. The
relocated call is the same blocking read as before, only earlier -- the
sole production caller of fork_main_into_worker, launch_new_worker,
always passes Some(listeners) and always sends a manifest, so a fresh
start receives an empty one immediately and every listener binds its own
socket exactly as it always did.

Ownership is settled before the descriptor leaves the table rather than
after. Each arm of notify_activate_listener asks the proxy
inherited_socket_fate(&address), which answers one of three things.
Adopted -- a listener is there and not active -- takes it. Refused -- a
listener is there and already active on a socket of its own -- takes it
and closes it deliberately, with a warn naming the address: activate()
short-circuits so it could never be adopted, and keeping it would leave
the retiring worker's socket in that address's SO_REUSEPORT group with
no event loop behind it, taking a share of connections nothing accepts
(inferred from SO_REUSEPORT semantics, not measured). Unclaimed -- no
listener at the address -- keeps it, because an AddListener plus
ActivateListener can still adopt it; that is how an upgrade whose
initial state carries the listeners inactive works, so closing leftovers
at the end of startup would destroy the case this commit fixes. No point
during startup makes a leftover provably unclaimable, so retention stays
open-ended and Server::new reports what it kept: info when the address
has a listener awaiting activation, warn when it has none at all.

A third copy lived on the registration-error path. activate() moved the
socket into a local to register it and propagated a Registry::register
failure straight from there, so the `?` dropped the local and closed a
descriptor Listeners::get_* had already removed. register answers EEXIST
for a descriptor already registered on the same epoll instance, which is
what notify_deactivate_listener leaves behind when its deregister only
logs. All four activate() implementations now park the socket on the
listener before propagating the error and reuse a parked socket on the
next attempt instead of binding a second one; active stays false
throughout, so nothing observes a half-activated listener.

Listeners::get_udp gains the removal post-conditions its three siblings
already assert.

doc/upgrade_e2e_tests.md stated the old ordering as the root cause of
its own scenarios, lib/src/protocol/udp/LIFECYCLE.md claimed the
re-exec'd worker adopts the passed fd, and the comment in
e2e/src/sozu/worker.rs justified its deactivate-then-activate sequence
by the defect; all three are corrected. This commit's own citations are
symbol anchors rather than line numbers, following the convention PR
#1366 established -- they had rotted twice across review rounds already.
The pre-existing citations it moves are re-anchored to the line each
already pointed at, resolved by content.

Closes #1342

Signed-off-by: Florentin Dubois <[email protected]>
FlorentinDUBOIS added a commit that referenced this pull request Sep 20, 2026
… them

A worker upgrade hands the retiring worker's listening sockets to its
replacement over SCM_RIGHTS. The replacement discarded all of them, on
all four protocols.

Server::new applied the initial state -- which generate_requests builds
as one AddXxxListener immediately followed by one ActivateListener per
active listener -- before it called receive_listeners(). scm_listeners
was therefore still None for the whole initial state, so every
ActivateListener took the server_bind / udp_bind branch and the listener
came up active on a socket it had bound itself. That bind succeeds only
because both helpers set SO_REUSEPORT, which is also why this never
surfaced as an outage: the address kept being served throughout.

The inherited descriptors arrived immediately afterwards, and
UpgradeWorkerTask then scattered generate_activate_requests() to the new
worker. Each repeat pulled its descriptor out of the SCM table --
Listeners::get_http and friends remove the entry as they hand it over --
wrapped it in an owning MioTcpListener / MioUdpSocket, and handed it to
an activate() that returns on its `if self.active` guard before it can
consume it. The wrapper dropped and the descriptor closed, once per
listener per upgrade: the accept backlog for TCP/HTTP/HTTPS, so a
connection that had completed its handshake against the old socket got
an RST instead of being served, and the receive buffer for UDP.

Three changes, one per place a descriptor could be lost.

Server::new receives the SCM listeners before it applies the initial
state, so the first ActivateListener adopts the inherited descriptor and
the later repeats find nothing left to discard. No socket is replaced
under a live listener: at that point the listener was created by the
AddXxxListener on the line above and holds no socket at all. The
relocated call is the same blocking read as before, only earlier -- the
sole production caller of fork_main_into_worker, launch_new_worker,
always passes Some(listeners) and always sends a manifest, so a fresh
start receives an empty one immediately and every listener binds its own
socket exactly as it always did.

Ownership is settled before the descriptor leaves the table rather than
after. Each arm of notify_activate_listener asks the proxy
inherited_socket_fate(&address), which answers one of three things.
Adopted -- a listener is there and not active -- takes it. Refused -- a
listener is there and already active on a socket of its own -- takes it
and closes it deliberately, with a warn naming the address. Not because
it could never be adopted: give_back_listener clears active and keeps
the listener object, so DeactivateListener then ActivateListener -- an
operator-reachable feature covered by listener_reactivation_tests.rs --
brings that address back to Adopted, and scm_listeners is filled once
and never refilled, so the close is irreversible. It is a trade. The
descriptor carries only the connections queued on it at hand-off, whose
value decays as those peers time out while the address is served by the
listener's own socket; the cost of keeping it is continuous, because it
stays bound with SO_REUSEPORT and registered with no event loop and is
expected to go on taking a share of new connections nothing accepts.
That expectation follows from SO_REUSEPORT load-balancing semantics and
nothing here measures it, which the enum doc, the helper doc, the test
doc and both operator-facing warn strings say too. Unclaimed -- no
listener at the address -- keeps it, because an AddListener plus
ActivateListener can still adopt it; that is how an upgrade whose
initial state carries the listeners inactive works, so closing leftovers
at the end of startup would destroy the case this commit fixes. No point
during startup makes a leftover provably unclaimable, so retention stays
open-ended and Server::new reports what it kept: info when the address
has a listener awaiting activation, warn when it has none at all.

A third copy lived on the registration-error path. activate() moved the
socket into a local to register it and propagated a Registry::register
failure straight from there, so the `?` dropped the local and closed a
descriptor Listeners::get_* had already removed. All four activate()
implementations now park that socket and reuse it on the next attempt
instead of binding a second one.

The park lives in a new parked_listener / parked_socket field, not in
the listener's live socket field. Every other consumer reads that
field's Some as "registered and live": give_back_listener hands it back
as an activated socket and answers Ok, soft_stop and hard_stop
deregister it and fold a failure into ProxyError::SoftStop / HardStop,
accept accepts on it. Parking there made a listener that never came up
look activated. Nothing but activate() reads the new field. If an
inherited socket and a parked one ever coexist, the loser is closed
explicitly and logged rather than dropped by an assignment.

Listeners::get_udp gains the removal post-conditions its three siblings
already assert.

doc/upgrade_e2e_tests.md stated the old ordering as the root cause of
its own scenarios, lib/src/protocol/udp/LIFECYCLE.md claimed the
re-exec'd worker adopts the passed fd, and the comment in
e2e/src/sozu/worker.rs justified its deactivate-then-activate sequence
by the defect; all three are corrected. The citations this commit
authors are symbol anchors rather than line numbers, following the
convention PR #1366 established -- numbering them rotted twice across
review rounds. The pre-existing citations it moves are re-anchored by
content where the cited line is unambiguous, and turned into symbol
anchors where the number resolved to something other than what its
sentence names.

Closes #1342

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the docs/lifecycle-citation-repair branch from ce5266f to 6691847 Compare September 20, 2026 16:04
517 `file.rs:NNN` anchors across `bin/src/command/LIFECYCLE.md`,
`lib/src/protocol/kawa_h1/LIFECYCLE.md`, `lib/src/protocol/mux/LIFECYCLE.md`,
`lib/src/protocol/proxy_protocol/LIFECYCLE.md` and
`lib/src/protocol/udp/LIFECYCLE.md` were read against the code they point at.
310 did not need a line number and are now symbol anchors; of the 207 that
name a specific statement or branch, 171 had to be renumbered and 36 were
already right.

A line number has no anchor, so it rots the moment anyone edits above it, and
nothing resolves it: a mechanical scan for a missing target, a line past EOF or
a blank line flagged only 27 of the 517. The two drift patterns measured in
issue #1335 account for nearly all of the rest — single-line anchors off by +1
from the `//!` module-doc line added at the top of each source file after the
documents were written, and ranges off by tens to thousands of lines from the
TigerStyle `debug_assert!` campaign and the growth of
`lib/src/protocol/mux/h2.rs`, where the drift reaches +2165.

The convention now matches `lib/src/protocol/tcp_preread/LIFECYCLE.md`, which
was already written this way and is why it needed no repair. Where the prose
names an item the anchor is that item plus its file, with a method qualified
`Type::method` so it is greppable; a line or range survives only where the
claim is about a statement or a branch inside an item. Bare basenames that were
ambiguous repo-wide (`server.rs`, `backends.rs`, `upgrade.rs`) are now
repo-root-relative. Each of the five preambles states the convention and the
date the surviving numbers were refreshed.

No prose claim was rewritten to match code. Four stale claims surfaced on the
way — `Server::run`, `upgrade_main`'s file, `ListenerAnswers` / `ClusterAnswers`
and the mux "inline removal" list — and are anchored correctly but left for a
separate pass. `doc/` is untouched.

Rebased onto 95c5f37 (#1369), whose H2 timer-ownership move drifted five more
citations in these same documents. Four were caught by the guard landing in
#1371 -- `editor.rs:561-621`, `h2.rs:6045-6047` and `manager.rs:555-567` twice,
each now resolving to a blank line -- and are re-anchored on
`HttpContext::on_request_headers`, the three `ConnectionH2` frame handlers that
decrement `active_requests`, and `UdpManager::handle_timeout`.

The fifth the guard cannot see, and it is the more instructive one:
`shrink_trailing_recycle`'s "single call site at `mod.rs:616`" now lands on
`HttpContext::new`, 58 lines short of the real call at `mod.rs:674`. A citation
that drifts onto a different non-blank line passes the check -- the checker says
so in its own output -- which is why the anchor is now `Mux::create_stream`.

The rebase also took the `mux/LIFECYCLE.md` backend-timeout tracker from
95c5f37, whose description is current, but symbolised its two citations rather
than keeping either side's numbers: `mod.rs:773` had come to land on unrelated
doc prose and `mod.rs:1279` on a `gauge_add!` call.

Refs #1335

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS force-pushed the docs/lifecycle-citation-repair branch from 6691847 to 07574ad Compare September 20, 2026 18:40
FlorentinDUBOIS added a commit that referenced this pull request Sep 20, 2026
… them

A worker upgrade hands the retiring worker's listening sockets to its
replacement over SCM_RIGHTS. The replacement discarded all of them, on
all four protocols.

Server::new applied the initial state -- which generate_requests builds
as one AddXxxListener immediately followed by one ActivateListener per
active listener -- before it called receive_listeners(). scm_listeners
was therefore still None for the whole initial state, so every
ActivateListener took the server_bind / udp_bind branch and the listener
came up active on a socket it had bound itself. That bind succeeds only
because both helpers set SO_REUSEPORT, which is also why this never
surfaced as an outage: the address kept being served throughout.

The inherited descriptors arrived immediately afterwards, and
UpgradeWorkerTask then scattered generate_activate_requests() to the new
worker. Each repeat pulled its descriptor out of the SCM table --
Listeners::get_http and friends remove the entry as they hand it over --
wrapped it in an owning MioTcpListener / MioUdpSocket, and handed it to
an activate() that returns on its `if self.active` guard before it can
consume it. The wrapper dropped and the descriptor closed, once per
listener per upgrade: the accept backlog for TCP/HTTP/HTTPS, so a
connection that had completed its handshake against the old socket got
an RST instead of being served, and the receive buffer for UDP.

Three changes, one per place a descriptor could be lost.

Server::new receives the SCM listeners before it applies the initial
state, so the first ActivateListener adopts the inherited descriptor and
the later repeats find nothing left to discard. No socket is replaced
under a live listener: at that point the listener was created by the
AddXxxListener on the line above and holds no socket at all. The
relocated call is the same blocking read as before, only earlier -- the
sole production caller of fork_main_into_worker, launch_new_worker,
always passes Some(listeners) and always sends a manifest, so a fresh
start receives an empty one immediately and every listener binds its own
socket exactly as it always did.

Ownership is settled before the descriptor leaves the table rather than
after. Each arm of notify_activate_listener asks the proxy
inherited_socket_fate(&address), which answers one of three things.
Adopted -- a listener is there and not active -- takes it. Refused -- a
listener is there and already active on a socket of its own -- takes it
and closes it deliberately, with a warn naming the address. Not because
it could never be adopted: give_back_listener clears active and keeps
the listener object, so DeactivateListener then ActivateListener -- an
operator-reachable feature covered by listener_reactivation_tests.rs --
brings that address back to Adopted, and scm_listeners is filled once
and never refilled, so the close is irreversible. It is a trade. The
descriptor carries only the connections queued on it at hand-off, whose
value decays as those peers time out while the address is served by the
listener's own socket; the cost of keeping it is continuous, because it
stays bound with SO_REUSEPORT and registered with no event loop and is
expected to go on taking a share of new connections nothing accepts.
That expectation follows from SO_REUSEPORT load-balancing semantics and
nothing here measures it, which the enum doc, the helper doc, the test
doc and both operator-facing warn strings say too. Unclaimed -- no
listener at the address -- keeps it, because an AddListener plus
ActivateListener can still adopt it; that is how an upgrade whose
initial state carries the listeners inactive works, so closing leftovers
at the end of startup would destroy the case this commit fixes. No point
during startup makes a leftover provably unclaimable, so retention stays
open-ended and Server::new reports what it kept: info when the address
has a listener awaiting activation, warn when it has none at all.

A third copy lived on the registration-error path. activate() moved the
socket into a local to register it and propagated a Registry::register
failure straight from there, so the `?` dropped the local and closed a
descriptor Listeners::get_* had already removed. All four activate()
implementations now park that socket and reuse it on the next attempt
instead of binding a second one.

The park lives in a new parked_listener / parked_socket field, not in
the listener's live socket field. Every other consumer reads that
field's Some as "registered and live": give_back_listener hands it back
as an activated socket and answers Ok, soft_stop and hard_stop
deregister it and fold a failure into ProxyError::SoftStop / HardStop,
accept accepts on it. Parking there made a listener that never came up
look activated. Nothing but activate() reads the new field. If an
inherited socket and a parked one ever coexist, the loser is closed
explicitly and logged rather than dropped by an assignment.

Listeners::get_udp gains the removal post-conditions its three siblings
already assert.

doc/upgrade_e2e_tests.md stated the old ordering as the root cause of
its own scenarios, lib/src/protocol/udp/LIFECYCLE.md claimed the
re-exec'd worker adopts the passed fd, and the comment in
e2e/src/sozu/worker.rs justified its deactivate-then-activate sequence
by the defect; all three are corrected. The citations this commit
authors are symbol anchors rather than line numbers, following the
convention PR #1366 established -- numbering them rotted twice across
review rounds. The pre-existing citations it moves are re-anchored by
content where the cited line is unambiguous, and turned into symbol
anchors where the number resolved to something other than what its
sentence names.

Rebased onto the docs-citation stack. This commit adds 1242 lines to
lib/src/server.rs, which drifts the two `epoll_time` citations in
doc/lifetime_of_a_session.md onto a blank line; they are re-anchored on
`names::event_loop::EPOLL_TIME` in `Server::run`. Neither this branch nor
the citation guard could see that alone -- on this branch the citations read
`server.rs:593-595` and `:594`, roughly 478 lines from the real site, and a
citation that lands on a different non-blank line passes the check. Only the
merged tree puts the range end on a blank line and fails.

Closes #1342

Signed-off-by: Florentin Dubois <[email protected]>
@FlorentinDUBOIS
FlorentinDUBOIS merged commit ec271d7 into main Sep 20, 2026
16 of 18 checks passed
@FlorentinDUBOIS
FlorentinDUBOIS deleted the docs/lifecycle-citation-repair branch September 20, 2026 19:21
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.

1 participant