cosmetic nit: now that every branch returns, i think plain ifs (without else) would read a bit nicer here. right now, the comments sit between a return true; and the next } else if, so they look like they belong to the previous block (kind of puzzled me at first glance but later on i realised what you meant). with separate ifs each comment lands right above the condition it explains, and the behavior would be identical. sth like:
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index dc2b8e8310..86696d2c69 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -1175,30 +1175,31 @@ bool HTTPRemoteClient::ShouldDisconnect(MockableSteadyClock::time_point now, std
if (m_disconnect) {
// We should already have logged the reason when we set m_disconnect.
return true;
+ }
// Check for idle timeout. We reset the timer when we send and receive data,
// but if the server is busy handling a request we should ignore the timeout until
// the reply is sent. If we did erase the shared_ptr<HTTPRemoteClient> reference in m_connected
// while the server is busy with a request, it might be prematurely dropped before
// the response has been sent, or if the HTTPRequest was holding a temporary shared_ptr
// client on a worker thread - it would keep the socket open even after "disconnecting".
- } else if (rpcservertimeout.count() > 0 &&
- now - m_idle_since.load() > rpcservertimeout &&
- !m_req_busy) {
+ if (rpcservertimeout.count() > 0 &&
+ now - m_idle_since.load() > rpcservertimeout &&
+ !m_req_busy) {
LogDebug(BCLog::HTTP,
"HTTP client idle timeout %s (id=%llu)",
m_origin,
m_id);
return true;
+ }
// Disconnect this client because the server is shutting down and we need to
// disconnect all clients... Unless the client is still being handled by a
// worker thread, in which case we'd rather continue the I/O loop (but might
// not complete sending back the full response).
- } else if (disconnect_all && !m_connection_busy) {
+ if (disconnect_all && !m_connection_busy) {
return true;
- } else {
- // No reason to disconnect.
- return false;
}
+ // No reason to disconnect.
+ return false;
}
void HTTPServer::ClearConnectedClients()
non-blocking, it is :)