Skip to content

Commit

Permalink
Merge bitcoin#27949: http: update libevent workaround to correct version
Browse files Browse the repository at this point in the history
79d343a http: update libevent workaround to correct version (stickies-v)

Pull request description:

  The libevent bug described in libevent/libevent@5ff8eb2 was already patched in [release-2.1.9-beta](https://github.com/libevent/libevent/releases/tag/release-2.1.9-beta), with cherry-picked commits [5b40744d1581447f5b4496ee8d4807383e468e7a](libevent/libevent@5b40744) and [b25813800f97179b2355a7b4b3557e6a7f568df2](libevent/libevent@b258138).

  There should be no side-effects by re-applying the workaround on an already patched version of libevent (as is currently done in master for people running libevent between 2.1.9 and 2.1.12), but it is best to just set the correct version number to avoid confusion.

  This will prevent situations like e.g. in bitcoin#27909 (comment), where a reverse workaround was incorrectly applied to the wrong version range.

ACKs for top commit:
  fanquake:
    ACK 79d343a

Tree-SHA512: 56d2576411cf38e56d0976523fec951e032a48e35af293ed1ef3af820af940b26f779b9197baaed6d8b79bd1c7f7334646b9d73f80610d63cffbc955958ca8a0
  • Loading branch information
fanquake authored and sidhujag committed Jun 30, 2023
1 parent 61be3dd commit 2e3d241
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/httpserver.cpp
Expand Up @@ -221,8 +221,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);
Expand Down Expand Up @@ -601,7 +603,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);
Expand Down

0 comments on commit 2e3d241

Please sign in to comment.