aboutsummaryrefslogtreecommitdiff
path: root/src/httpserver.cpp
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2017-04-10 10:27:36 -0400
committerJohn Newbery <john@johnnewbery.com>2017-04-10 17:05:59 -0400
commit4d9950d3bc72d92a0ee9a33ab3b77e097eb77354 (patch)
tree8f90e8eb86ddbb1980beb7a361a0d08bedf4f9cb /src/httpserver.cpp
parente19586a8a95502ce0f9fb8319ca6456c2ce161b3 (diff)
Set BCLog::LIBEVENT correctly for old libevent versions.
Diffstat (limited to 'src/httpserver.cpp')
-rw-r--r--src/httpserver.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/httpserver.cpp b/src/httpserver.cpp
index 347433eb11..e7df23295d 100644
--- a/src/httpserver.cpp
+++ b/src/httpserver.cpp
@@ -384,15 +384,13 @@ bool InitHTTPServer()
// Redirect libevent's logging to our own log
event_set_log_callback(&libevent_log_cb);
-#if LIBEVENT_VERSION_NUMBER >= 0x02010100
- // If -debug=libevent, set full libevent debugging.
- // Otherwise, disable all libevent debugging.
- if (LogAcceptCategory(BCLog::LIBEVENT)) {
- event_enable_debug_logging(EVENT_DBG_ALL);
- } else {
- event_enable_debug_logging(EVENT_DBG_NONE);
+ // Update libevent's log handling. Returns false if our version of
+ // libevent doesn't support debug logging, in which case we should
+ // clear the BCLog::LIBEVENT flag.
+ if (!UpdateHTTPServerLogging(logCategories & BCLog::LIBEVENT)) {
+ logCategories &= ~BCLog::LIBEVENT;
}
-#endif
+
#ifdef WIN32
evthread_use_windows_threads();
#else
@@ -435,6 +433,20 @@ bool InitHTTPServer()
return true;
}
+bool UpdateHTTPServerLogging(bool enable) {
+#if LIBEVENT_VERSION_NUMBER >= 0x02010100
+ if (enable) {
+ event_enable_debug_logging(EVENT_DBG_ALL);
+ } else {
+ event_enable_debug_logging(EVENT_DBG_NONE);
+ }
+ return true;
+#else
+ // Can't update libevent logging if version < 02010100
+ return false;
+#endif
+}
+
std::thread threadHTTP;
std::future<bool> threadResult;