Skip to content

Commit

Permalink
Merge bitcoin/bitcoin#27949: http: update libevent workaround to corr…
Browse files Browse the repository at this point in the history
…ect version

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/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 committed Jun 28, 2023
2 parents ec822e8 + 79d343a commit a15388c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/httpserver.cpp
Original file line number Diff line number Diff line change
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 a15388c

Please sign in to comment.