[PR #5930] [MERGED] Server: connections whose peer stops reading free their place #6569

Closed
opened 2026-11-03 06:23:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5930
Author: @ludovic111
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @ludovic111

Base: main ← Head: fix/connection-write-timeout


📝 Commits (1)

  • 1dc2f50 lan: a write waits at most 30 s; log places closing

📊 Changes

2 files changed (+16 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/lan/conn.rs (+9 -0)
📝 crates/horizon-client/src/lan/mod.rs (+7 -2)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

Follow-up to #5923 (issue #5901). Since #5923 the official server's 133 connection places stay full: about 65 addresses hold them, but only about 37 players are online. make_room keeps joins working by closing the oldest connections not yet in play, but places held by connections that already reached play are never freed.

  • Writes time out after 30 s, like reads. A peer that stops reading (a frozen game, a dropped network) left the connection's writer blocked on a full send buffer. On Linux, TCP keeps retrying for about 15 min, and a live but frozen peer advertises a zero window that never times out. play() joins that writer before it ends, so the thread and the connection's place stayed taken. A write error already ends the writer, so the connection now ends at most 30 s after the read times out. Vanilla closes the channel on its keep-alive timeout, which drops pending writes the same way.
  • The turned-away report breaks the places down: how many are before play and how many are closing (play ended, writer not finished yet). The remainder are in play. Once deployed, this shows whether places are still held by connections that never end.

Per-connection cost: one socket option at accept and two atomic adds when play ends.

Local check: a horizon-bots player frozen with SIGSTOP in game. On macOS the loopback buffer never filled, so the writer didn't block, and with the old build (without this change) both threads ended at the 30 s read timeout: no leak to show. That's why the report line is part of this PR: the live server will measure what the test could not.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 9543d2a68, 4 min 57 s)

Check Result
Scope ✅ 2 files, +299 −14
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (58 s)
rustfmt ✅ (5 s)
clippy ✅ (13 s)
tests: horizon-client ✅ 1680 passed (3 min 15 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ 36 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, lan and 24 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/5930 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/connection-write-timeout` --- ### 📝 Commits (1) - [`1dc2f50`](https://github.com/horizon-rust/horizon/commit/1dc2f505bb1d72a871948ae0763001810644fc64) lan: a write waits at most 30 s; log places closing ### 📊 Changes **2 files changed** (+16 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/lan/conn.rs` (+9 -0) 📝 `crates/horizon-client/src/lan/mod.rs` (+7 -2) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Follow-up to #5923 (issue #5901). Since #5923 the official server's 133 connection places stay full: about 65 addresses hold them, but only about 37 players are online. make_room keeps joins working by closing the oldest connections not yet in play, but places held by connections that already reached play are never freed. - **Writes time out after 30 s, like reads.** A peer that stops reading (a frozen game, a dropped network) left the connection's writer blocked on a full send buffer. On Linux, TCP keeps retrying for about 15 min, and a live but frozen peer advertises a zero window that never times out. `play()` joins that writer before it ends, so the thread and the connection's place stayed taken. A write error already ends the writer, so the connection now ends at most 30 s after the read times out. Vanilla closes the channel on its keep-alive timeout, which drops pending writes the same way. - **The turned-away report breaks the places down**: how many are before play and how many are closing (play ended, writer not finished yet). The remainder are in play. Once deployed, this shows whether places are still held by connections that never end. Per-connection cost: one socket option at accept and two atomic adds when play ends. Local check: a horizon-bots player frozen with SIGSTOP in game. On macOS the loopback buffer never filled, so the writer didn't block, and with the old build (without this change) both threads ended at the 30 s read timeout: no leak to show. That's why the report line is part of this PR: the live server will measure what the test could not. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 9543d2a68, 4 min 57 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +299 −14 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (58 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (13 s) | | tests: horizon-client | ✅ 1680 passed (3 min 15 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ 36 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, lan and 24 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:23:11 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#6569
No description provided.