mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
Merge bitcoin/bitcoin#24681: build: Bump libevent minimum version up to 2.1.8
e40779a4fe
refactor: Remove outdated libevent logging code (Fabian Jahr)0598f36852
refactor: account for requiring libevent 2.1.8+ (fanquake)aaf72d62c1
build: Bump libevent minimum version up to 2.1.8 (Hennadii Stepanov) Pull request description: Required to support new functionality in bitcoin/bitcoin#19420. `libevent` availability: https://repology.org/project/libevent/versions ACKs for top commit: laanwj: Code review ACKe40779a4fe
fanquake: ACKe40779a4fe
Tree-SHA512: ccb14ea2f591484a3df5bc4a19f4f5400ef6b1cfb7dc45dd99f96cb948748215ed3b5debc34869763c91b8c7a26993fdb9b870950c0743c4d01038ab27c5e4e2
This commit is contained in:
commit
d906329c28
7 changed files with 12 additions and 51 deletions
|
@ -1537,9 +1537,9 @@ fi
|
||||||
dnl libevent check
|
dnl libevent check
|
||||||
|
|
||||||
if test "$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench" != "nonononono"; then
|
if test "$build_bitcoin_cli$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench" != "nonononono"; then
|
||||||
PKG_CHECK_MODULES([EVENT], [libevent >= 2.0.21], [use_libevent=yes], [AC_MSG_ERROR([libevent version 2.0.21 or greater not found.])])
|
PKG_CHECK_MODULES([EVENT], [libevent >= 2.1.8], [use_libevent=yes], [AC_MSG_ERROR([libevent version 2.1.8 or greater not found.])])
|
||||||
if test "$TARGET_OS" != "windows"; then
|
if test "$TARGET_OS" != "windows"; then
|
||||||
PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads >= 2.0.21],, [AC_MSG_ERROR([libevent_pthreads version 2.0.21 or greater not found.])])
|
PKG_CHECK_MODULES([EVENT_PTHREADS], [libevent_pthreads >= 2.1.8], [], [AC_MSG_ERROR([libevent_pthreads version 2.1.8 or greater not found.])])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "$suppress_external_warnings" != "no"; then
|
if test "$suppress_external_warnings" != "no"; then
|
||||||
|
|
|
@ -18,7 +18,7 @@ You can find installation instructions in the `build-*.md` file for your platfor
|
||||||
| Dependency | Version used | Minimum required | Runtime |
|
| Dependency | Version used | Minimum required | Runtime |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| [Boost](https://www.boost.org/users/download/) | 1.77.0 | [1.64.0](https://github.com/bitcoin/bitcoin/pull/22320) | No |
|
| [Boost](https://www.boost.org/users/download/) | 1.77.0 | [1.64.0](https://github.com/bitcoin/bitcoin/pull/22320) | No |
|
||||||
| [libevent](https://github.com/libevent/libevent/releases) | 2.1.12-stable | [2.0.21](https://github.com/bitcoin/bitcoin/pull/18676) | No |
|
| [libevent](https://github.com/libevent/libevent/releases) | 2.1.12-stable | [2.1.8](https://github.com/bitcoin/bitcoin/pull/24681) | No |
|
||||||
| [glibc](https://www.gnu.org/software/libc/) | N/A | [2.18](https://github.com/bitcoin/bitcoin/pull/23511) | Yes |
|
| [glibc](https://www.gnu.org/software/libc/) | N/A | [2.18](https://github.com/bitcoin/bitcoin/pull/23511) | Yes |
|
||||||
|
|
||||||
## Optional
|
## Optional
|
||||||
|
|
|
@ -184,7 +184,6 @@ struct HTTPReply
|
||||||
static std::string http_errorstring(int code)
|
static std::string http_errorstring(int code)
|
||||||
{
|
{
|
||||||
switch(code) {
|
switch(code) {
|
||||||
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
|
|
||||||
case EVREQ_HTTP_TIMEOUT:
|
case EVREQ_HTTP_TIMEOUT:
|
||||||
return "timeout reached";
|
return "timeout reached";
|
||||||
case EVREQ_HTTP_EOF:
|
case EVREQ_HTTP_EOF:
|
||||||
|
@ -197,7 +196,6 @@ static std::string http_errorstring(int code)
|
||||||
return "request was canceled";
|
return "request was canceled";
|
||||||
case EVREQ_HTTP_DATA_TOO_LONG:
|
case EVREQ_HTTP_DATA_TOO_LONG:
|
||||||
return "response body is larger than allowed";
|
return "response body is larger than allowed";
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
@ -228,13 +226,11 @@ static void http_request_done(struct evhttp_request *req, void *ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
|
|
||||||
static void http_error_cb(enum evhttp_request_error err, void *ctx)
|
static void http_error_cb(enum evhttp_request_error err, void *ctx)
|
||||||
{
|
{
|
||||||
HTTPReply *reply = static_cast<HTTPReply*>(ctx);
|
HTTPReply *reply = static_cast<HTTPReply*>(ctx);
|
||||||
reply->error = err;
|
reply->error = err;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Class that handles the conversion from a command-line to a JSON-RPC request,
|
/** Class that handles the conversion from a command-line to a JSON-RPC request,
|
||||||
* as well as converting back to a JSON object that can be shown as result.
|
* as well as converting back to a JSON object that can be shown as result.
|
||||||
|
@ -745,11 +741,11 @@ static UniValue CallRPC(BaseRequestHandler* rh, const std::string& strMethod, co
|
||||||
|
|
||||||
HTTPReply response;
|
HTTPReply response;
|
||||||
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
|
raii_evhttp_request req = obtain_evhttp_request(http_request_done, (void*)&response);
|
||||||
if (req == nullptr)
|
if (req == nullptr) {
|
||||||
throw std::runtime_error("create http request failed");
|
throw std::runtime_error("create http request failed");
|
||||||
#if LIBEVENT_VERSION_NUMBER >= 0x02010300
|
}
|
||||||
|
|
||||||
evhttp_request_set_error_cb(req.get(), http_error_cb);
|
evhttp_request_set_error_cb(req.get(), http_error_cb);
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get credentials
|
// Get credentials
|
||||||
std::string strRPCUserColonPass;
|
std::string strRPCUserColonPass;
|
||||||
|
|
|
@ -360,12 +360,8 @@ bool InitHTTPServer()
|
||||||
|
|
||||||
// Redirect libevent's logging to our own log
|
// Redirect libevent's logging to our own log
|
||||||
event_set_log_callback(&libevent_log_cb);
|
event_set_log_callback(&libevent_log_cb);
|
||||||
// Update libevent's log handling. Returns false if our version of
|
// Update libevent's log handling.
|
||||||
// libevent doesn't support debug logging, in which case we should
|
UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT));
|
||||||
// clear the BCLog::LIBEVENT flag.
|
|
||||||
if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
|
|
||||||
LogInstance().DisableCategory(BCLog::LIBEVENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
evthread_use_windows_threads();
|
evthread_use_windows_threads();
|
||||||
|
@ -404,18 +400,12 @@ bool InitHTTPServer()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateHTTPServerLogging(bool enable) {
|
void UpdateHTTPServerLogging(bool enable) {
|
||||||
#if LIBEVENT_VERSION_NUMBER >= 0x02010100
|
|
||||||
if (enable) {
|
if (enable) {
|
||||||
event_enable_debug_logging(EVENT_DBG_ALL);
|
event_enable_debug_logging(EVENT_DBG_ALL);
|
||||||
} else {
|
} else {
|
||||||
event_enable_debug_logging(EVENT_DBG_NONE);
|
event_enable_debug_logging(EVENT_DBG_NONE);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
// Can't update libevent logging if version < 02010100
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::thread g_thread_http;
|
static std::thread g_thread_http;
|
||||||
|
|
|
@ -32,9 +32,8 @@ void InterruptHTTPServer();
|
||||||
/** Stop HTTP server */
|
/** Stop HTTP server */
|
||||||
void StopHTTPServer();
|
void StopHTTPServer();
|
||||||
|
|
||||||
/** Change logging level for libevent. Removes BCLog::LIBEVENT from log categories if
|
/** Change logging level for libevent. */
|
||||||
* libevent doesn't support debug logging.*/
|
void UpdateHTTPServerLogging(bool enable);
|
||||||
bool UpdateHTTPServerLogging(bool enable);
|
|
||||||
|
|
||||||
/** Handler for requests to a certain HTTP path */
|
/** Handler for requests to a certain HTTP path */
|
||||||
typedef std::function<bool(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
|
typedef std::function<bool(HTTPRequest* req, const std::string &)> HTTPRequestHandler;
|
||||||
|
|
|
@ -646,17 +646,8 @@ static RPCHelpMan logging()
|
||||||
uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
|
uint32_t changed_log_categories = original_log_categories ^ updated_log_categories;
|
||||||
|
|
||||||
// Update libevent logging if BCLog::LIBEVENT has changed.
|
// Update libevent logging if BCLog::LIBEVENT has changed.
|
||||||
// If the library version doesn't allow it, UpdateHTTPServerLogging() returns false,
|
|
||||||
// in which case we should clear the BCLog::LIBEVENT flag.
|
|
||||||
// Throw an error if the user has explicitly asked to change only the libevent
|
|
||||||
// flag and it failed.
|
|
||||||
if (changed_log_categories & BCLog::LIBEVENT) {
|
if (changed_log_categories & BCLog::LIBEVENT) {
|
||||||
if (!UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT))) {
|
UpdateHTTPServerLogging(LogInstance().WillLogCategory(BCLog::LIBEVENT));
|
||||||
LogInstance().DisableCategory(BCLog::LIBEVENT);
|
|
||||||
if (changed_log_categories == BCLog::LIBEVENT) {
|
|
||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue result(UniValue::VOBJ);
|
UniValue result(UniValue::VOBJ);
|
||||||
|
|
|
@ -19,23 +19,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// workaround for libevent versions before 2.1.1,
|
|
||||||
// when internal functions didn't have underscores at the end
|
|
||||||
#if LIBEVENT_VERSION_NUMBER < 0x02010100
|
|
||||||
extern "C" int evhttp_parse_firstline(struct evhttp_request*, struct evbuffer*);
|
|
||||||
extern "C" int evhttp_parse_headers(struct evhttp_request*, struct evbuffer*);
|
|
||||||
inline int evhttp_parse_firstline_(struct evhttp_request* r, struct evbuffer* b)
|
|
||||||
{
|
|
||||||
return evhttp_parse_firstline(r, b);
|
|
||||||
}
|
|
||||||
inline int evhttp_parse_headers_(struct evhttp_request* r, struct evbuffer* b)
|
|
||||||
{
|
|
||||||
return evhttp_parse_headers(r, b);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
extern "C" int evhttp_parse_firstline_(struct evhttp_request*, struct evbuffer*);
|
extern "C" int evhttp_parse_firstline_(struct evhttp_request*, struct evbuffer*);
|
||||||
extern "C" int evhttp_parse_headers_(struct evhttp_request*, struct evbuffer*);
|
extern "C" int evhttp_parse_headers_(struct evhttp_request*, struct evbuffer*);
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string RequestMethodString(HTTPRequest::RequestMethod m);
|
std::string RequestMethodString(HTTPRequest::RequestMethod m);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue