http: disconnect clients that never finish a request

bitcoin/bitcoin: PR #36204

3 suggestions

Earlier concerns neither republished nor resolved: 1 minor finding · 1 suggestion. See the Run archive for their assessments.

Optional improvements

Link

[suggestion] · Completion deadline also caps body uploads that are still progressing

At the default 30-second timeout, the new deadline can disconnect a standalone RPC body upload despite continuous progress, unlike the base's idle-only timeout; no affected production upload has been established.

Location: src/httpserver.cpp:1115 (head).

Details and suggested fix

m_request_since remains armed until the entire request is parsed, including its body, while later reads refresh only m_idle_since. If the body remains incomplete when the I/O loop checks after the deadline, the server closes the connection without an HTTP status. A permitted 32 MiB body needs roughly 1.1 MiB/s to fit within this budget. Response-write restarts do not help a standalone upload with no earlier reply pending.

If this total-time limit is intended, add a release note explaining that it covers body uploads and that raising -rpcservertimeout also lengthens the idle timeout, while setting it to zero disables both timers. The unchanged help text does not explain this compatibility change. If slow uploads should remain supported, retain the fixed header deadline and bound bodies by byte progress instead; returning bodies to inactivity-only protection would reopen body trickling.


Link

[suggestion] · Idle expiry masks the pipelined request's completion deadline

The I/O-loop test would still pass if the completion deadline were never armed for the leftover second request, because its final disconnect is already required by the idle timeout.

Location: src/test/httpserver_tests.cpp:1062 (head).

Details and suggested fix

The drain steps assert only that the connection survives. After the reply drains, advancing timeout + 1s without traffic expires the idle timer, which ShouldDisconnect() checks before the completion deadline. Add a unit case that buffers a complete /a followed by an incomplete /b, takes /a, and calls TryReadRequest() again while /a is still busy. Advance past the timeout, write /a's reply, parse the leftover bytes, and assert that the client stays connected. Then advance another timeout + 1s, refresh only the idle timestamp with NotIdleAt(now()), and assert disconnection. This checks that the leftover request gets a fresh deadline after worker deferral and that its deadline can expire independently of inactivity.


Link

[suggestion] · Deadline log capture starts after the sender

A main-thread delay before log capture can make the functional test miss a correct deadline-disconnect message and fail spuriously; this race is source-inferred, not an observed test failure.

Location: test/functional/interface_http.py:491 (head).

Details and suggested fix

assert_debug_log() searches only output written after its context is entered. The sender starts before that point, and the main thread still has to open the waiting connection and set its timeout. With RPCSERVERTIMEOUT = 2, an uncommon delay of roughly two seconds in that window can let the sender and server finish the deadline interaction before the helper records its offset. Enter the log context before starting the sender, take start immediately before the thread start, and keep the waiting-client and timing assertions inside the context.


Coverage details

Earlier concerns

Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.