http: Use new max connection limit from libevent 2.2

This commit is contained in:
Fabian Jahr 2023-05-23 17:46:45 +02:00
parent eb0bdbdd75
commit 5e8eccceac
No known key found for this signature in database
GPG key ID: F13D1E9D890798CD

View file

@ -465,6 +465,15 @@ bool InitHTTPServer(const util::SignalInterrupt& interrupt)
int workQueueDepth = std::max((long)gArgs.GetIntArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L); int workQueueDepth = std::max((long)gArgs.GetIntArg("-rpcworkqueue", DEFAULT_HTTP_WORKQUEUE), 1L);
LogDebug(BCLog::HTTP, "creating work queue of depth %d\n", workQueueDepth); LogDebug(BCLog::HTTP, "creating work queue of depth %d\n", workQueueDepth);
#if LIBEVENT_VERSION_NUMBER >= 0x02020001
if (event_get_version_number() >= 0x02020001) {
// Limit the maximum number of open connections to prevent exhausting
// the file descriptor limit. When the http server gets overwhelmed it
// will respond with 503 Service Unavailable.
evhttp_set_max_connections(http, workQueueDepth * 2);
}
#endif
g_work_queue = std::make_unique<WorkQueue<HTTPClosure>>(workQueueDepth); g_work_queue = std::make_unique<WorkQueue<HTTPClosure>>(workQueueDepth);
// transfer ownership to eventBase/HTTP via .release() // transfer ownership to eventBase/HTTP via .release()
eventBase = base_ctr.release(); eventBase = base_ctr.release();