mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
Fixed logger thread start/stop logic
This commit is contained in:
parent
4d16c77f73
commit
2f08a35ac7
1 changed files with 9 additions and 0 deletions
|
@ -31,6 +31,7 @@ namespace log {
|
|||
int GLOBAL_LOG_LEVEL = 5;
|
||||
|
||||
static volatile bool stopped = false;
|
||||
static volatile bool worker_started = false;
|
||||
|
||||
#ifdef _WIN32
|
||||
static const HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
@ -61,6 +62,8 @@ public:
|
|||
uv_mutex_init(&m_mutex);
|
||||
uv_thread_create(&m_worker, run_wrapper, this);
|
||||
|
||||
do {} while (!worker_started);
|
||||
|
||||
#ifdef _WIN32
|
||||
DWORD dwConsoleMode;
|
||||
if (GetConsoleMode(hStdOut, &dwConsoleMode)) {
|
||||
|
@ -82,6 +85,10 @@ public:
|
|||
|
||||
FORCEINLINE void stop()
|
||||
{
|
||||
if (stopped) {
|
||||
return;
|
||||
}
|
||||
|
||||
stopped = true;
|
||||
LOGINFO(0, "stopped");
|
||||
uv_thread_join(&m_worker);
|
||||
|
@ -121,6 +128,8 @@ private:
|
|||
|
||||
NOINLINE void run()
|
||||
{
|
||||
worker_started = true;
|
||||
|
||||
do {
|
||||
uv_mutex_lock(&m_mutex);
|
||||
uv_cond_wait(&m_cond, &m_mutex);
|
||||
|
|
Loading…
Reference in a new issue