mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
ipc, refactor: Update mp::g_thread_context references
Use new CurrentThread function to be compatible with windows mingw bug workaround https://github.com/bitcoin-core/libmultiprocess/pull/318
This commit is contained in:
@@ -94,7 +94,7 @@ public:
|
||||
void serve(interfaces::Init& init, const std::function<mp::Stream()>& make_stream) override
|
||||
{
|
||||
assert(!m_loop);
|
||||
mp::g_thread_context.thread_name = mp::ThreadName(m_exe_name);
|
||||
mp::CurrentThread().thread_name = mp::ThreadName(m_exe_name);
|
||||
mp::LogOptions opts = {
|
||||
.log_fn = IpcLogFn,
|
||||
.log_level = GetRequestedIPCLogLevel()
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <primitives/transaction.h>
|
||||
#include <capnp/capability.h>
|
||||
#include <capnp/rpc.h>
|
||||
#include <ipc/util.h>
|
||||
#include <kj/memory.h>
|
||||
#include <mp/proxy-io.h>
|
||||
#include <mp/proxy.h>
|
||||
@@ -78,10 +79,10 @@ static void initialize_ipc()
|
||||
static const auto testing_setup = MakeNoLogFileContext<>();
|
||||
(void)testing_setup;
|
||||
|
||||
// Ensure g_thread_context is destroyed after the IPC setup, since C++
|
||||
// destroys thread_local objects in reverse construction order.
|
||||
mp::ThreadContext& thread_context{mp::g_thread_context};
|
||||
(void)thread_context;
|
||||
// Ensure the thread's ThreadContext is created before the IPC setup, so
|
||||
// it is destroyed after it, since C++ destroys thread_local objects in
|
||||
// reverse construction order.
|
||||
mp::CurrentThread();
|
||||
|
||||
thread_local static IpcFuzzSetup ipc; // NOLINT(bitcoin-nontrivial-threadlocal)
|
||||
g_ipc = &ipc;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <kj/debug.h>
|
||||
#include <mp/proxy-io.h>
|
||||
#include <mp/util.h>
|
||||
#include <mp/version.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -52,6 +53,11 @@ inline SocketId StartSpawned(const std::string& connect_info)
|
||||
if (!socket) throw std::invalid_argument(strprintf("Invalid socket descriptor '%s'", connect_info));
|
||||
return *socket;
|
||||
}
|
||||
|
||||
inline ThreadContext& CurrentThread()
|
||||
{
|
||||
return g_thread_context;
|
||||
}
|
||||
#endif
|
||||
} // namespace mp
|
||||
|
||||
|
||||
Reference in New Issue
Block a user