allow libevent logging to be updated during runtime
This commit is contained in:
parent
5255aca3f4
commit
7fd50c3b70
3 changed files with 17 additions and 2 deletions
|
@ -97,7 +97,7 @@ endif
|
|||
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
|
||||
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS) $(EVENT_CFLAGS)
|
||||
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS)
|
||||
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1) $(EVENT_LIBS) $(EVENT_PTHREADS_LIBS)
|
||||
test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
if ENABLE_WALLET
|
||||
test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "clientversion.h"
|
||||
#include "init.h"
|
||||
#include "validation.h"
|
||||
#include "httpserver.h"
|
||||
#include "net.h"
|
||||
#include "netbase.h"
|
||||
#include "rpc/blockchain.h"
|
||||
|
@ -598,6 +599,20 @@ UniValue logging(const JSONRPCRequest& request)
|
|||
logCategories &= ~getCategoryMask(request.params[1]);
|
||||
}
|
||||
|
||||
// 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.
|
||||
uint32_t changedLogCategories = originalLogCategories ^ logCategories;
|
||||
if (changedLogCategories & BCLog::LIBEVENT) {
|
||||
if (!UpdateHTTPServerLogging(logCategories & BCLog::LIBEVENT)) {
|
||||
logCategories &= ~BCLog::LIBEVENT;
|
||||
if (changedLogCategories == BCLog::LIBEVENT) {
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "libevent logging cannot be updated when using libevent before v2.1.1.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UniValue result(UniValue::VOBJ);
|
||||
std::vector<CLogCategoryActive> vLogCatActive = ListActiveLogCategories();
|
||||
|
|
|
@ -118,7 +118,7 @@ bool fLogIPs = DEFAULT_LOGIPS;
|
|||
std::atomic<bool> fReopenDebugLog(false);
|
||||
CTranslationInterface translationInterface;
|
||||
|
||||
/** Log categories bitfield. libevent needs special handling if their flags are changed at runtime. */
|
||||
/** Log categories bitfield. */
|
||||
std::atomic<uint32_t> logCategories(0);
|
||||
|
||||
/** Init OpenSSL library multithreading support */
|
||||
|
|
Loading…
Reference in a new issue