Console: fixed data race

pull/271/head
SChernykh 1 year ago
parent 58d32ffd1f
commit 98a9eb4f18

@ -63,12 +63,18 @@ ConsoleCommands::ConsoleCommands(p2pool* pool)
throw std::exception(); throw std::exception();
} }
int err = uv_thread_create(&m_loopThread, loop, this); if (m_pool->api() && m_pool->params().m_localStats) {
if (err) { m_pool->api()->set(p2pool_api::Category::LOCAL, "console",
LOGERR(1, "failed to start event loop thread, error " << uv_err_name(err)); [stdin_type, this](log::Stream& s)
PANIC_STOP(); {
s << "{\"mode\":" << ((stdin_type == UV_TTY) ? "\"tty\"" : "\"pipe\"")
<< ",\"tcp_port\":" << m_listenPort
<< "}";
});
} }
int err;
if (stdin_type == UV_TTY) { if (stdin_type == UV_TTY) {
LOGINFO(3, "processing stdin as UV_TTY"); LOGINFO(3, "processing stdin as UV_TTY");
err = uv_tty_init(&m_loop, &m_tty, 0, 1); err = uv_tty_init(&m_loop, &m_tty, 0, 1);
@ -100,14 +106,10 @@ ConsoleCommands::ConsoleCommands(p2pool* pool)
throw std::exception(); throw std::exception();
} }
if (m_pool->api() && m_pool->params().m_localStats) { err = uv_thread_create(&m_loopThread, loop, this);
m_pool->api()->set(p2pool_api::Category::LOCAL, "console", if (err) {
[stdin_type, this](log::Stream& s) LOGERR(1, "failed to start event loop thread, error " << uv_err_name(err));
{ throw std::exception();
s << "{\"mode\":" << ((stdin_type == UV_TTY) ? "\"tty\"" : "\"pipe\"")
<< ",\"tcp_port\":" << m_listenPort
<< "}";
});
} }
} }

Loading…
Cancel
Save