Loading src/http.h +3 −0 Changes for src/http.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -678,6 +678,9 @@ namespace libhttppp { int tid = 0; ULONG_PTR args = 0; size_t emptyCount = 0; // Start of the current run of empty ResponseEvent reads (set when // emptyCount leaves 0); the stall abort is time-based off this. std::chrono::steady_clock::time_point emptySince{}; unsigned int backoffMs = 1; bool finished = false; // Set while totalSent < contentLength and the peer's flow-control Loading src/httpd.cpp +11 −2 Changes for src/httpd.cpp: 11 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -91,6 +91,13 @@ static constexpr int64_t H2_MAX_WINDOW_SIZE = 0x7fffffff; // side until it tears down the TCP connection itself. static constexpr std::chrono::seconds H2_WINDOW_STALL_TIMEOUT{30}; // 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- // clock bound: the resume loop re-polls as fast as the socket is writable, // so an iteration count (the former `emptyCount > 500`) expired after a few // milliseconds and reset healthy streams on any brief upstream hiccup. static constexpr std::chrono::seconds H2_UPSTREAM_STALL_TIMEOUT{30}; static const char H2_CLIENT_PREFACE[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; static constexpr size_t H2_CLIENT_PREFACE_LEN = 24; Loading Loading @@ -1604,8 +1611,10 @@ void libhttppp::HttpEvent::_resumeH2Streams(HttpRequest &cureq, // arrived" was self-referential and reset emptyCount every // single time, so the stall counter below could never // advance and a permanently-stalled upstream spun forever. ++ss->emptyCount; if (ss->emptyCount > 500) { const auto now = std::chrono::steady_clock::now(); if (ss->emptyCount++ == 0) ss->emptySince = now; if (now - ss->emptySince > H2_UPSTREAM_STALL_TIMEOUT) { // Genuine stall with the response short of the // advertised Content-Length. Sending END_STREAM here // would make the client accept a truncated body as Loading Loading
src/http.h +3 −0 Changes for src/http.h: 3 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -678,6 +678,9 @@ namespace libhttppp { int tid = 0; ULONG_PTR args = 0; size_t emptyCount = 0; // Start of the current run of empty ResponseEvent reads (set when // emptyCount leaves 0); the stall abort is time-based off this. std::chrono::steady_clock::time_point emptySince{}; unsigned int backoffMs = 1; bool finished = false; // Set while totalSent < contentLength and the peer's flow-control Loading
src/httpd.cpp +11 −2 Changes for src/httpd.cpp: 11 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -91,6 +91,13 @@ static constexpr int64_t H2_MAX_WINDOW_SIZE = 0x7fffffff; // side until it tears down the TCP connection itself. static constexpr std::chrono::seconds H2_WINDOW_STALL_TIMEOUT{30}; // 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- // clock bound: the resume loop re-polls as fast as the socket is writable, // so an iteration count (the former `emptyCount > 500`) expired after a few // milliseconds and reset healthy streams on any brief upstream hiccup. static constexpr std::chrono::seconds H2_UPSTREAM_STALL_TIMEOUT{30}; static const char H2_CLIENT_PREFACE[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; static constexpr size_t H2_CLIENT_PREFACE_LEN = 24; Loading Loading @@ -1604,8 +1611,10 @@ void libhttppp::HttpEvent::_resumeH2Streams(HttpRequest &cureq, // arrived" was self-referential and reset emptyCount every // single time, so the stall counter below could never // advance and a permanently-stalled upstream spun forever. ++ss->emptyCount; if (ss->emptyCount > 500) { const auto now = std::chrono::steady_clock::now(); if (ss->emptyCount++ == 0) ss->emptySince = now; if (now - ss->emptySince > H2_UPSTREAM_STALL_TIMEOUT) { // Genuine stall with the response short of the // advertised Content-Length. Sending END_STREAM here // would make the client accept a truncated body as Loading