Skip to content

Commit 8ab4f28

Browse files
author
MarcoFalke
committed
Merge #15622: Remove global symbols: Avoid using the global namespace if possible
fb43415 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
2 parents e043bfc + fb43415 commit 8ab4f28

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/httpserver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ struct HTTPPathHandler
139139
//! libevent event loop
140140
static struct event_base* eventBase = nullptr;
141141
//! HTTP server
142-
struct evhttp* eventHTTP = nullptr;
142+
static struct evhttp* eventHTTP = nullptr;
143143
//! List of subnets to allow RPC connections from
144144
static std::vector<CSubNet> rpc_allow_subnets;
145145
//! Work queue for handling longer requests off the event loop thread
146146
static WorkQueue<HTTPClosure>* workQueue = nullptr;
147147
//! Handlers for (sub)paths
148-
std::vector<HTTPPathHandler> pathHandlers;
148+
static std::vector<HTTPPathHandler> pathHandlers;
149149
//! Bound listening sockets
150-
std::vector<evhttp_bound_socket *> boundSockets;
150+
static std::vector<evhttp_bound_socket *> boundSockets;
151151

152152
/** Check if a network address is allowed to access the HTTP server */
153153
static bool ClientAllowed(const CNetAddr& netaddr)
@@ -420,7 +420,7 @@ bool UpdateHTTPServerLogging(bool enable) {
420420
#endif
421421
}
422422

423-
std::thread threadHTTP;
423+
static std::thread threadHTTP;
424424
static std::vector<std::thread> g_thread_http_workers;
425425

426426
void StartHTTPServer()

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
#include <zmq/zmqrpc.h>
7575
#endif
7676

77-
bool fFeeEstimatesInitialized = false;
77+
static bool fFeeEstimatesInitialized = false;
7878
static const bool DEFAULT_PROXYRANDOMIZE = true;
7979
static const bool DEFAULT_REST_ENABLE = false;
8080
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;

src/warnings.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
#include <util/system.h>
99
#include <warnings.h>
1010

11-
CCriticalSection cs_warnings;
12-
std::string strMiscWarning GUARDED_BY(cs_warnings);
13-
bool fLargeWorkForkFound GUARDED_BY(cs_warnings) = false;
14-
bool fLargeWorkInvalidChainFound GUARDED_BY(cs_warnings) = false;
11+
static RecursiveMutex cs_warnings;
12+
static std::string strMiscWarning GUARDED_BY(cs_warnings);
13+
static bool fLargeWorkForkFound GUARDED_BY(cs_warnings) = false;
14+
static bool fLargeWorkInvalidChainFound GUARDED_BY(cs_warnings) = false;
1515

1616
void SetMiscWarning(const std::string& strWarning)
1717
{

0 commit comments

Comments
 (0)