mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 13:42:10 +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
|
void serve(interfaces::Init& init, const std::function<mp::Stream()>& make_stream) override
|
||||||
{
|
{
|
||||||
assert(!m_loop);
|
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 = {
|
mp::LogOptions opts = {
|
||||||
.log_fn = IpcLogFn,
|
.log_fn = IpcLogFn,
|
||||||
.log_level = GetRequestedIPCLogLevel()
|
.log_level = GetRequestedIPCLogLevel()
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <primitives/transaction.h>
|
#include <primitives/transaction.h>
|
||||||
#include <capnp/capability.h>
|
#include <capnp/capability.h>
|
||||||
#include <capnp/rpc.h>
|
#include <capnp/rpc.h>
|
||||||
|
#include <ipc/util.h>
|
||||||
#include <kj/memory.h>
|
#include <kj/memory.h>
|
||||||
#include <mp/proxy-io.h>
|
#include <mp/proxy-io.h>
|
||||||
#include <mp/proxy.h>
|
#include <mp/proxy.h>
|
||||||
@@ -78,10 +79,10 @@ static void initialize_ipc()
|
|||||||
static const auto testing_setup = MakeNoLogFileContext<>();
|
static const auto testing_setup = MakeNoLogFileContext<>();
|
||||||
(void)testing_setup;
|
(void)testing_setup;
|
||||||
|
|
||||||
// Ensure g_thread_context is destroyed after the IPC setup, since C++
|
// Ensure the thread's ThreadContext is created before the IPC setup, so
|
||||||
// destroys thread_local objects in reverse construction order.
|
// it is destroyed after it, since C++ destroys thread_local objects in
|
||||||
mp::ThreadContext& thread_context{mp::g_thread_context};
|
// reverse construction order.
|
||||||
(void)thread_context;
|
mp::CurrentThread();
|
||||||
|
|
||||||
thread_local static IpcFuzzSetup ipc; // NOLINT(bitcoin-nontrivial-threadlocal)
|
thread_local static IpcFuzzSetup ipc; // NOLINT(bitcoin-nontrivial-threadlocal)
|
||||||
g_ipc = &ipc;
|
g_ipc = &ipc;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <kj/debug.h>
|
#include <kj/debug.h>
|
||||||
|
#include <mp/proxy-io.h>
|
||||||
#include <mp/util.h>
|
#include <mp/util.h>
|
||||||
#include <mp/version.h>
|
#include <mp/version.h>
|
||||||
#include <sys/socket.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));
|
if (!socket) throw std::invalid_argument(strprintf("Invalid socket descriptor '%s'", connect_info));
|
||||||
return *socket;
|
return *socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline ThreadContext& CurrentThread()
|
||||||
|
{
|
||||||
|
return g_thread_context;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
} // namespace mp
|
} // namespace mp
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user