From 6b4640c413aeaf35bfd5d3e49f4383944f4abfde Mon Sep 17 00:00:00 2001 From: SChernykh Date: Mon, 2 May 2022 21:24:51 +0200 Subject: [PATCH] Fixes for Termux --- CMakeLists.txt | 10 +++++++++- src/console_commands.cpp | 6 +++++- src/p2p_server.cpp | 2 +- src/util.cpp | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6df26ce..bd050a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -100,7 +100,7 @@ if (WIN32) elseif (CMAKE_SYSTEM_NAME STREQUAL FreeBSD) set(LIBS ${LIBS} pthread) elseif (NOT APPLE) - set(LIBS ${LIBS} pthread gss dl) + set(LIBS ${LIBS} pthread dl) endif() if (CMAKE_CXX_COMPILER_ID MATCHES MSVC) @@ -133,6 +133,14 @@ endif() add_definitions(/DZMQ_STATIC) +include(CheckSymbolExists) + +check_symbol_exists(pthread_cancel pthread.h HAVE_PTHREAD_CANCEL) + +if (HAVE_PTHREAD_CANCEL) + add_definitions(/DHAVE_PTHREAD_CANCEL) +endif() + add_executable(${CMAKE_PROJECT_NAME} ${HEADERS} ${SOURCES}) if (STATIC_BINARY) diff --git a/src/console_commands.cpp b/src/console_commands.cpp index dee7dd5..ae59325 100644 --- a/src/console_commands.cpp +++ b/src/console_commands.cpp @@ -27,6 +27,10 @@ #include "side_chain.h" #include +#ifdef HAVE_PTHREAD_CANCEL +#include +#endif + static constexpr char log_category_prefix[] = "ConsoleCommands "; namespace p2pool { @@ -45,7 +49,7 @@ ConsoleCommands::~ConsoleCommands() #ifdef _WIN32 TerminateThread(reinterpret_cast(m_worker->native_handle()), 0); -#else +#elif defined HAVE_PTHREAD_CANCEL pthread_cancel(m_worker->native_handle()); #endif diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index 51055a2..40bc43b 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -417,7 +417,7 @@ void P2PServer::load_peer_list() addrinfo hints{}; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; + hints.ai_flags = AI_ADDRCONFIG; addrinfo* result; const int err = getaddrinfo(nodes[i], nullptr, &hints, &result); diff --git a/src/util.cpp b/src/util.cpp index b004743..7b261a3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -349,7 +349,7 @@ bool resolve_host(std::string& host, bool& is_v6) addrinfo hints{}; hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG; + hints.ai_flags = AI_ADDRCONFIG; addrinfo* r = nullptr; const int err = getaddrinfo(host.c_str(), nullptr, &hints, &r);