From 74a2557245ae416b70e6d1671a61e9405848999d Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sat, 25 May 2019 18:37:04 -0400 Subject: [PATCH] Merge #15622: Remove global symbols: Avoid using the global namespace if possible fb434159d1 Remove global symbols: Avoid using the global namespace if possible (practicalswift) Pull request description: Remove global symbols: Avoid using the global namespace if possible. Partially resolves #15612 ("Reduce the number of global symbols used"). Change in global symbols as reported by `nm bitcoind` before vs after: ``` $ diff -u <(nm src/bitcoind-before | c++filt | grep -E '^[0-9a-f]+ [A-Z] ' | cut -f3- -d' ' | sort -u) \ <(nm src/bitcoind-after | c++filt | grep -E '^[0-9a-f]+ [A-Z] ' | cut -f3- -d' ' | sort -u) \ | grep -E '^[+-][^+-]' -boundSockets -cs_warnings -eventHTTP -fFeeEstimatesInitialized -fLargeWorkForkFound -fLargeWorkInvalidChainFound -pathHandlers -strMiscWarning[abi:cxx11] -threadHTTP ``` ACKs for commit fb4341: Tree-SHA512: d2f78f6188a992b0e0de8d107e2c494cfa0faa2de4fda634a1d3606d6515633bec86289cf2a2e78ffe467b17b795e2243cc459fb44e0dfe2fc69899506ff61c9 --- src/httpserver.cpp | 8 ++++---- src/init.cpp | 2 +- src/warnings.cpp | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 34947f59f9..f07a8f3c76 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -143,15 +143,15 @@ struct HTTPPathHandler //! libevent event loop static struct event_base* eventBase = nullptr; //! HTTP server -struct evhttp* eventHTTP = nullptr; +static struct evhttp* eventHTTP = nullptr; //! List of subnets to allow RPC connections from static std::vector rpc_allow_subnets; //! Work queue for handling longer requests off the event loop thread static WorkQueue* workQueue = nullptr; //! Handlers for (sub)paths -std::vector pathHandlers; +static std::vector pathHandlers; //! Bound listening sockets -std::vector boundSockets; +static std::vector boundSockets; /** Check if a network address is allowed to access the HTTP server */ static bool ClientAllowed(const CNetAddr& netaddr) @@ -428,7 +428,7 @@ bool UpdateHTTPServerLogging(bool enable) { #endif } -std::thread threadHTTP; +static std::thread threadHTTP; static std::vector g_thread_http_workers; void StartHTTPServer() diff --git a/src/init.cpp b/src/init.cpp index 8324def820..cb806e70c8 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -104,7 +104,7 @@ #include #endif -bool fFeeEstimatesInitialized = false; +static bool fFeeEstimatesInitialized = false; static const bool DEFAULT_PROXYRANDOMIZE = true; static const bool DEFAULT_REST_ENABLE = false; static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false; diff --git a/src/warnings.cpp b/src/warnings.cpp index 47e3856ce2..a25077079f 100644 --- a/src/warnings.cpp +++ b/src/warnings.cpp @@ -9,10 +9,10 @@ #include #include -CCriticalSection cs_warnings; -std::string strMiscWarning GUARDED_BY(cs_warnings); -bool fLargeWorkForkFound GUARDED_BY(cs_warnings) = false; -bool fLargeWorkInvalidChainFound GUARDED_BY(cs_warnings) = false; +static RecursiveMutex cs_warnings; +static std::string strMiscWarning GUARDED_BY(cs_warnings); +static bool fLargeWorkForkFound GUARDED_BY(cs_warnings) = false; +static bool fLargeWorkInvalidChainFound GUARDED_BY(cs_warnings) = false; void SetMiscWarning(const std::string& strWarning) {