From 79d343a642f985801da463b03a0627a59a095238 Mon Sep 17 00:00:00 2001 From: stickies-v Date: Fri, 23 Jun 2023 17:11:08 +0100 Subject: [PATCH] http: update libevent workaround to correct version The libevent bug described in https://github.com/libevent/libevent/commit/5ff8eb26371c4dc56f384b2de35bea2d87814779 was already patched in release-2.1.9-beta, with cherry-picked commits 5b40744d1581447f5b4496ee8d4807383e468e7a and b25813800f97179b2355a7b4b3557e6a7f568df2. There should be no side-effects by re-applying the workaround on an already patched version of libevent, but it is best to set the correct version number to avoid confusion. --- src/httpserver.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 128c4e3c56..c27578403d 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -222,8 +222,10 @@ static void http_request_cb(struct evhttp_request* req, void* arg) }, nullptr); } - // Disable reading to work around a libevent bug, fixed in 2.2.0. - if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02020001) { + // Disable reading to work around a libevent bug, fixed in 2.1.9 + // See https://github.com/libevent/libevent/commit/5ff8eb26371c4dc56f384b2de35bea2d87814779 + // and https://github.com/bitcoin/bitcoin/pull/11593. + if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02010900) { evhttp_connection* conn = evhttp_request_get_connection(req); if (conn) { bufferevent* bev = evhttp_connection_get_bufferevent(conn); @@ -604,7 +606,7 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply) evhttp_send_reply(req_copy, nStatus, nullptr, nullptr); // Re-enable reading from the socket. This is the second part of the libevent // workaround above. - if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02020001) { + if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02010900) { evhttp_connection* conn = evhttp_request_get_connection(req_copy); if (conn) { bufferevent* bev = evhttp_connection_get_bufferevent(conn);