diff --git a/src/log.cpp b/src/log.cpp index 9ee61f6..b078986 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -54,7 +54,7 @@ public: : m_writePos(0) , m_readPos(0) { - is_main_thread = true; + set_main_thread(); m_logFile.open(log_file_name, std::ios::app | std::ios::binary); diff --git a/src/p2pool.cpp b/src/p2pool.cpp index b3d7ed9..870c62e 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -226,7 +226,7 @@ void p2pool::handle_miner_data(MinerData& data) "\n---------------------------------------------------------------------------------------------------------------" ); - if (!is_main_thread) { + if (!is_main_thread()) { update_block_template_async(); } else { diff --git a/src/util.cpp b/src/util.cpp index 19f944c..fdc0b72 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -225,7 +225,7 @@ void uv_rwlock_init_checked(uv_rwlock_t* lock) uv_loop_t* uv_default_loop_checked() { - if (!is_main_thread) { + if (!is_main_thread()) { LOGERR(1, "uv_default_loop() can only be used by the main thread. Fix the code!"); #ifdef _WIN32 if (IsDebuggerPresent()) { @@ -339,7 +339,10 @@ void BackgroundJobTracker::print_status() } BackgroundJobTracker bkg_jobs_tracker; -thread_local bool is_main_thread = false; + +static thread_local bool main_thread = false; +void set_main_thread() { main_thread = true; } +bool is_main_thread() { return main_thread; } bool resolve_host(std::string& host, bool& is_v6) { diff --git a/src/util.h b/src/util.h index 073a351..74f2f2a 100644 --- a/src/util.h +++ b/src/util.h @@ -133,7 +133,9 @@ private: }; extern BackgroundJobTracker bkg_jobs_tracker; -extern thread_local bool is_main_thread; + +void set_main_thread(); +bool is_main_thread(); bool resolve_host(std::string& host, bool& is_v6);