Archived
server: bound what an unauthenticated socket can make the transport hold
Three ways a client spent the server's patience or memory without ever being admitted: The gate's 401 answers before any handler sees the request, so its body sits unread on a keep-alive socket, and httplib's anti-smuggling drain will wait for it: one byte per read timeout paces a whole worker, at the pacing client's chosen rate. The refusal now closes the connection instead, says so on the response, and buries the body with the socket -- which is also what makes draining a refusal pointless. A drain that does have a purpose -- a framed body on a request the router answered without reading it -- inherits the stream's 30 s read wait per packet gap and no total bound at all. It keeps both waits now: five seconds per gap (the stream's own set_read_timeout, the same knob the WebSocket upgrade uses) and five in total (a deadline the discard provider checks), then the connection dies and the timeout is restored for whatever the connection still has coming. And bodies. The per-request cap bounds one body and no sum, every byte of a body is buffered before parse, admission or any accounting sees it, and a few hundred concurrent large POSTs is an OOM that reaches the engine before any refusal does. read_and_bridge now holds every buffered byte against a transport-wide budget and answers 429 with Retry-After to the newcomer the budget has no room for; the reservation releases on every exit, including the peer vanishing mid-body. The budget defaults to eight bodies at the per-request cap and moves through ServerOptions::max_inflight_body_bytes. Vendor: the two httplib hunks are recorded as patches/0022, and UPSTREAM's "no file content differs" for the pair is replaced with what the split actually is and what is now edited in it. transport_test: a_refusal_closes_the_connection, a_stalled_drain_dies_on_its_deadline, the_inflight_body_budget. ASan+UBSan: transport/wire/lifecycle/server/config/diag/dashboard, 7/7.
This commit is contained in:
1 parent
ec53bce5dc
commit
5f7244da4d
8 files changed
+268
-12
No files matched your search
@@ -276,6 +276,7 @@ int Server::run() {
|
||||
t.write_timeout_s = opt_.write_timeout_s;
|
||||
t.keep_alive_timeout_s = opt_.keep_alive_timeout_s;
|
||||
t.max_body_bytes = opt_.max_body_bytes;
|
||||
t.max_inflight_body_bytes = opt_.max_inflight_body_bytes;
|
||||
return transport_.serve(router_, t);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user