Repository navigation
fix(links): the public link router keeps its connections, checked per request (#559) - #560
Merged
Merged
Conversation
… request (#559) The router behind a named tunnel (hub and node) opened a new connection to the service for every request and closed it first, leaving each in TIME_WAIT for two minutes, the class #556 fixed for `forward`. Its `Dial` was also the owner's check that a host is open, so a plain pool by host would have passed a closed link. `Dial` now only checks and returns a `Way` (target key, port, TLS, and the future that connects: TCP on the hub, the lane's tunnel on a node). It is called for every request; only then the router takes a kept connection for that target from `connpool::Pool`, or opens one, and gives it back through `GiveBack`. Connections are keyed by the target, never by the host name. ADR-0091 amended with the review card the owner approved. Closes #559 Bug-Class: connection-per-request Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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 and why
The public link router (
linkrouter.rs, used by the hub and by a node) opened a new connection to the service for every request and closed it first — theconnection-per-requestclass #556/#557 fixed forforwardand the hub's way to its daemons. It was left out there becauseDialwas both the way to the service and the owner's check that a link is open: a pool by host would have passed a closed link.Dialnow only checks: it returns aWay(key= the target,port,tls, andopen, the future that connects) and opens nothing. It is called for every request.connpool::PoolbyWay::key, uses a kept connection or opens one alongopen(TLS on top where the service speaks it), resends a request a kept connection handed back unsent, and returns connections throughGiveBack. Upgrades keep their own.publiclinks.rs):routeas before,linkrouter::local(port, tls)is now aWaykeyedlocal:<port>:<tls>.node/links.rs): registered host and lease checked as before; the lane daemon's look-up and its tunnel moved intoopen, keyedlane:<lease>:<port>:<tls>, so the tunnel is reused with its connection.Closes #559
Review card
Approved by the owner in the conversation on 2026-11-17, all three points.
Decided on my own:
linkrouter::Dialchanges shape (an internal Rust interface); point 2 departs from the issue's own proposal to drop connections when a link closes, since point 1 already protects.Verified (Windows)
linkrouter::tests::the_router_reuses_its_connections_to_a_service: red onmain("20 requests opened 20 connections"), green here (≤ 2). In the same test: after the link closes, a request is a404while a connection to the service is kept; opened again, the next request is served without a new connection (proving it was kept).only_what_the_dial_knows_is_servedunchanged and green.cargo fmt,cargo clippy -D warnings,cargo test --workspace.remote-lane.Bug class:
connection-per-request.🤖 Generated with Claude Code