Loading src/httpd.cpp +14 −10 Changes for src/httpd.cpp: 14 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -88,8 +88,10 @@ static constexpr int64_t H2_MAX_WINDOW_SIZE = 0x7fffffff; // it. Guards against a peer that silently stops crediting the window — // without this, the stream (and its per-stream tempreq) stays parked in // activeStreams forever and the connection looks hung from the client's // side until it tears down the TCP connection itself. static constexpr std::chrono::seconds H2_WINDOW_STALL_TIMEOUT{30}; // side until it tears down the TCP connection itself. Generous on purpose: // a slow consumer (git clone of a big pack on slow disk) legitimately stops // crediting the window for a while. static constexpr std::chrono::seconds H2_WINDOW_STALL_TIMEOUT{300}; // How long a streaming response's upstream (the app's ResponseEvent) may // keep producing zero bytes before the stream is aborted. Must be a wall- Loading Loading @@ -1673,7 +1675,8 @@ void libhttppp::HttpEvent::_reapStalledH2Streams(HttpRequest &cureq, // Peer never credited the window back — give up on this stream // instead of leaving it (and its tempreq) parked forever. uint8_t rst[4] = {0, 0, 0, 0x03}; // FLOW_CONTROL_ERROR // CANCEL, not FLOW_CONTROL_ERROR: the peer broke no rule, we gave up. uint8_t rst[4] = {0, 0, 0, 0x08}; // CANCEL out += h2BuildFrame(H2_FRAME_RST_STREAM, 0, sid, std::string(reinterpret_cast<char*>(rst), 4)); cureq.h2state().peerStreamWindows.erase(sid); Loading Loading @@ -1722,12 +1725,6 @@ bool libhttppp::HttpEvent::Http2RequestEvent(netplus::con &curcon, out += h2ConnectionWindowBoost(); } // Reap any streams that have been window-blocked past the stall // timeout before doing anything else — a new request coming in on an // otherwise-stuck connection is exactly the point where an old // zombie stream would never get cleaned up any other way. _reapStalledH2Streams(cureq, out); // Process all complete frames in RecvData reprocess: while (off + H2_FRAME_HEADER_LEN <= cureq.RecvData.size()) { Loading Loading @@ -2038,6 +2035,13 @@ reprocess: } done: // Reap streams that have been window-blocked past the stall timeout. // This must run *after* the frames above were processed: a peer that // paused reading (e.g. git's index-pack busy writing) sends exactly the // WINDOW_UPDATE that unblocks the stream once it resumes. Reaping first // reset that stream with FLOW_CONTROL_ERROR right as its credit arrived. _reapStalledH2Streams(cureq, out); if (!out.empty()) { cureq.SendData.append(out.data(), out.size()); } Loading Loading @@ -3122,7 +3126,7 @@ void libhttppp::HttpEvent::ResponseEvent(netplus::con &curcon,const int tid,ULON // Http2RequestEvent, which only runs when a new frame // arrives from the peer. A peer that stops crediting window // *and* stops sending any other frame at all never triggers // that path again, so the 30s stall it's meant to catch // that path again, so the window stall it's meant to catch // would otherwise never be detected on a connection driven // purely by writable/poll events (e.g. one already parked // here waiting on window credit). Loading Loading
src/httpd.cpp +14 −10 Changes for src/httpd.cpp: 14 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -88,8 +88,10 @@ static constexpr int64_t H2_MAX_WINDOW_SIZE = 0x7fffffff; // it. Guards against a peer that silently stops crediting the window — // without this, the stream (and its per-stream tempreq) stays parked in // activeStreams forever and the connection looks hung from the client's // side until it tears down the TCP connection itself. static constexpr std::chrono::seconds H2_WINDOW_STALL_TIMEOUT{30}; // side until it tears down the TCP connection itself. Generous on purpose: // a slow consumer (git clone of a big pack on slow disk) legitimately stops // crediting the window for a while. static constexpr std::chrono::seconds H2_WINDOW_STALL_TIMEOUT{300}; // How long a streaming response's upstream (the app's ResponseEvent) may // keep producing zero bytes before the stream is aborted. Must be a wall- Loading Loading @@ -1673,7 +1675,8 @@ void libhttppp::HttpEvent::_reapStalledH2Streams(HttpRequest &cureq, // Peer never credited the window back — give up on this stream // instead of leaving it (and its tempreq) parked forever. uint8_t rst[4] = {0, 0, 0, 0x03}; // FLOW_CONTROL_ERROR // CANCEL, not FLOW_CONTROL_ERROR: the peer broke no rule, we gave up. uint8_t rst[4] = {0, 0, 0, 0x08}; // CANCEL out += h2BuildFrame(H2_FRAME_RST_STREAM, 0, sid, std::string(reinterpret_cast<char*>(rst), 4)); cureq.h2state().peerStreamWindows.erase(sid); Loading Loading @@ -1722,12 +1725,6 @@ bool libhttppp::HttpEvent::Http2RequestEvent(netplus::con &curcon, out += h2ConnectionWindowBoost(); } // Reap any streams that have been window-blocked past the stall // timeout before doing anything else — a new request coming in on an // otherwise-stuck connection is exactly the point where an old // zombie stream would never get cleaned up any other way. _reapStalledH2Streams(cureq, out); // Process all complete frames in RecvData reprocess: while (off + H2_FRAME_HEADER_LEN <= cureq.RecvData.size()) { Loading Loading @@ -2038,6 +2035,13 @@ reprocess: } done: // Reap streams that have been window-blocked past the stall timeout. // This must run *after* the frames above were processed: a peer that // paused reading (e.g. git's index-pack busy writing) sends exactly the // WINDOW_UPDATE that unblocks the stream once it resumes. Reaping first // reset that stream with FLOW_CONTROL_ERROR right as its credit arrived. _reapStalledH2Streams(cureq, out); if (!out.empty()) { cureq.SendData.append(out.data(), out.size()); } Loading Loading @@ -3122,7 +3126,7 @@ void libhttppp::HttpEvent::ResponseEvent(netplus::con &curcon,const int tid,ULON // Http2RequestEvent, which only runs when a new frame // arrives from the peer. A peer that stops crediting window // *and* stops sending any other frame at all never triggers // that path again, so the 30s stall it's meant to catch // that path again, so the window stall it's meant to catch // would otherwise never be detected on a connection driven // purely by writable/poll events (e.g. one already parked // here waiting on window credit). Loading