Skip to content

Commit 084d037

Browse files
committed
http: log connection instead of request count
There is no significant benefit in logging the request count instead of the connection count. Reduces amount of code and computational complexity.
1 parent 41f9027 commit 084d037

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/httpserver.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <cstdlib>
2828
#include <deque>
2929
#include <memory>
30-
#include <numeric>
3130
#include <optional>
3231
#include <string>
3332
#include <unordered_map>
@@ -193,13 +192,6 @@ class HTTPRequestTracker
193192
auto it{m_tracker.find(Assert(conn))};
194193
if (it != m_tracker.end()) RemoveConnectionInternal(it);
195194
}
196-
197-
size_t CountActiveRequests() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
198-
{
199-
LOCK(m_mutex);
200-
return std::accumulate(m_tracker.begin(), m_tracker.end(), size_t(0),
201-
[](size_t acc_count, const auto& pair) { return acc_count + pair.second; });
202-
}
203195
size_t CountActiveConnections() const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
204196
{
205197
return WITH_LOCK(m_mutex, return m_tracker.size());
@@ -530,8 +522,8 @@ void StopHTTPServer()
530522
}
531523
boundSockets.clear();
532524
{
533-
if (g_requests.CountActiveConnections() != 0) {
534-
LogPrint(BCLog::HTTP, "Waiting for %d requests to stop HTTP server\n", g_requests.CountActiveRequests());
525+
if (const auto n_connections{g_requests.CountActiveConnections()}; n_connections != 0) {
526+
LogPrint(BCLog::HTTP, "Waiting for %d connections to stop HTTP server\n", n_connections);
535527
}
536528
g_requests.WaitUntilEmpty();
537529
}

0 commit comments

Comments
 (0)