From 44d2005ab1b1dd290d7d81d1bf7a8680ddf9a832 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Thu, 20 Apr 2023 10:59:32 +0200 Subject: [PATCH] Console: returned stdin check to constructor --- src/console_commands.cpp | 3 ++- src/log.cpp | 2 -- src/uv_util.h | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/console_commands.cpp b/src/console_commands.cpp index cacf3b6..003b1e3 100644 --- a/src/console_commands.cpp +++ b/src/console_commands.cpp @@ -43,6 +43,7 @@ ConsoleCommands::ConsoleCommands(p2pool* pool) , m_readBuf{} , m_readBufInUse(false) { + const uv_handle_type stdin_type = uv_guess_handle(0); LOGINFO(3, "uv_guess_handle returned " << static_cast(stdin_type)); if (stdin_type != UV_TTY && stdin_type != UV_NAMED_PIPE) { LOGERR(1, "tty or named pipe is not available"); @@ -101,7 +102,7 @@ ConsoleCommands::ConsoleCommands(p2pool* pool) if (m_pool->api() && m_pool->params().m_localStats) { m_pool->api()->set(p2pool_api::Category::LOCAL, "console", - [this](log::Stream& s) + [stdin_type, this](log::Stream& s) { s << "{\"mode\":" << ((stdin_type == UV_TTY) ? "\"tty\"" : "\"pipe\"") << ",\"tcp_port\":" << m_listenPort diff --git a/src/log.cpp b/src/log.cpp index 7f702b7..e1cdfb8 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -32,8 +32,6 @@ static constexpr char log_file_name[] = "p2pool.log"; namespace p2pool { -const uv_handle_type stdin_type = uv_guess_handle(0); - namespace log { int GLOBAL_LOG_LEVEL = 3; diff --git a/src/uv_util.h b/src/uv_util.h index 1709e8c..e4e6f0c 100644 --- a/src/uv_util.h +++ b/src/uv_util.h @@ -25,8 +25,6 @@ static_assert(sizeof(in_addr) == 4, "struct in_addr has invalid size"); namespace p2pool { -extern const uv_handle_type stdin_type; - struct MutexLock : public nocopy_nomove { explicit FORCEINLINE MutexLock(uv_mutex_t& handle) : m_handle(&handle) { uv_mutex_lock(&handle); }