rpc: further constrain the libevent workaround

The bug was introduced in 2.1.6-beta, versions before that don't need the
workaround.

zcash: currently, we build with libevent-2.1.12, so this fix is needed
zcash: cherry picked from commit 97932cd2689659addfbb58dc6148928b73af3bd0
zcash: https://github.com/bitcoin/bitcoin/pull/11593
This commit is contained in:
Cory Fields 2017-11-02 14:37:33 -04:00 committed by Larry Ruane
parent 92d8f1d5cc
commit af7914242d
1 changed files with 2 additions and 2 deletions

View File

@ -248,7 +248,7 @@ static std::string RequestMethodString(HTTPRequest::RequestMethod m)
static void http_request_cb(struct evhttp_request* req, void* arg) static void http_request_cb(struct evhttp_request* req, void* arg)
{ {
// Disable reading to work around a libevent bug, fixed in 2.2.0. // Disable reading to work around a libevent bug, fixed in 2.2.0.
if (event_get_version_number() < 0x02020001) { if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02020001) {
evhttp_connection* conn = evhttp_request_get_connection(req); evhttp_connection* conn = evhttp_request_get_connection(req);
if (conn) { if (conn) {
bufferevent* bev = evhttp_connection_get_bufferevent(conn); bufferevent* bev = evhttp_connection_get_bufferevent(conn);
@ -620,7 +620,7 @@ void HTTPRequest::WriteReply(int nStatus, const std::string& strReply)
evhttp_send_reply(req_copy, nStatus, nullptr, nullptr); evhttp_send_reply(req_copy, nStatus, nullptr, nullptr);
// Re-enable reading from the socket. This is the second part of the libevent // Re-enable reading from the socket. This is the second part of the libevent
// workaround above. // workaround above.
if (event_get_version_number() < 0x02020001) { if (event_get_version_number() >= 0x02010600 && event_get_version_number() < 0x02020001) {
evhttp_connection* conn = evhttp_request_get_connection(req_copy); evhttp_connection* conn = evhttp_request_get_connection(req_copy);
if (conn) { if (conn) {
bufferevent* bev = evhttp_connection_get_bufferevent(conn); bufferevent* bev = evhttp_connection_get_bufferevent(conn);