From 227f84fb8b042c55998e4fb166ef71f1dfb61175 Mon Sep 17 00:00:00 2001 From: Matej Kenda Date: Mon, 15 Dec 2025 21:39:38 +0100 Subject: [PATCH] fix(Net): Add POCO_HAS_UNIX_SOCKET guards to fix build without Unix sockets #5064 --- Data/ODBC/include/Poco/Data/ODBC/ODBC.h | 2 +- Foundation/include/Poco/Platform_POSIX.h | 10 ---------- Net/include/Poco/Net/SocketDefs.h | 3 ++- Net/src/HTTPSession.cpp | 2 ++ Net/src/SocketAddress.cpp | 2 ++ Net/src/WebSocketImpl.cpp | 2 ++ 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/Data/ODBC/include/Poco/Data/ODBC/ODBC.h b/Data/ODBC/include/Poco/Data/ODBC/ODBC.h index f415e4fbe..eafb62bc5 100644 --- a/Data/ODBC/include/Poco/Data/ODBC/ODBC.h +++ b/Data/ODBC/include/Poco/Data/ODBC/ODBC.h @@ -54,7 +54,7 @@ #include "Poco/Data/ODBC/Unicode.h" -#if (__cplusplus >= 201703L) +#if POCO_HAVE_CPP17_COMPILER #if __has_include() #include #define POCO_DATA_ODBC_HAVE_SQL_SERVER_EXT diff --git a/Foundation/include/Poco/Platform_POSIX.h b/Foundation/include/Poco/Platform_POSIX.h index 699735ea2..d356ea1e9 100644 --- a/Foundation/include/Poco/Platform_POSIX.h +++ b/Foundation/include/Poco/Platform_POSIX.h @@ -32,16 +32,6 @@ #endif -// -// Thread-safety of local static initialization -// -#if __cplusplus >= 201103L || __GNUC__ >= 4 || defined(__clang__) - #ifndef POCO_LOCAL_STATIC_INIT_IS_THREADSAFE - #define POCO_LOCAL_STATIC_INIT_IS_THREADSAFE 1 - #endif -#endif - - // // No syslog.h on QNX/BB10 // diff --git a/Net/include/Poco/Net/SocketDefs.h b/Net/include/Poco/Net/SocketDefs.h index 8806e80bd..9a66cd406 100644 --- a/Net/include/Poco/Net/SocketDefs.h +++ b/Net/include/Poco/Net/SocketDefs.h @@ -18,6 +18,7 @@ #define Net_SocketDefs_INCLUDED +#include "Poco/Config.h" #include @@ -33,7 +34,7 @@ #include #include #if !defined (POCO_NET_NO_UNIX_SOCKET) - #if (__cplusplus >= 201703L) + #if POCO_HAVE_CPP17_COMPILER #if __has_include() #include #define POCO_HAS_UNIX_SOCKET diff --git a/Net/src/HTTPSession.cpp b/Net/src/HTTPSession.cpp index 98dc20041..c8fc747a7 100644 --- a/Net/src/HTTPSession.cpp +++ b/Net/src/HTTPSession.cpp @@ -196,7 +196,9 @@ void HTTPSession::connect(const SocketAddress& address) _socket.connect(address, _connectionTimeout); _socket.setReceiveTimeout(_receiveTimeout); _socket.setSendTimeout(_sendTimeout); +#if defined(POCO_HAS_UNIX_SOCKET) if (address.family() != SocketAddress::UNIX_LOCAL) +#endif _socket.setNoDelay(true); // There may be leftover data from a previous (failed) request in the buffer, // so we clear it. diff --git a/Net/src/SocketAddress.cpp b/Net/src/SocketAddress.cpp index 3b26c90a9..864aa179e 100644 --- a/Net/src/SocketAddress.cpp +++ b/Net/src/SocketAddress.cpp @@ -380,11 +380,13 @@ void SocketAddress::init(const std::string& hostAndPort) { poco_assert (!hostAndPort.empty()); +#if defined(POCO_HAS_UNIX_SOCKET) if (isUnixLocal(hostAndPort)) { newLocal(hostAndPort); return; } +#endif std::string host; std::string port; diff --git a/Net/src/WebSocketImpl.cpp b/Net/src/WebSocketImpl.cpp index 795c6c706..392036a3b 100644 --- a/Net/src/WebSocketImpl.cpp +++ b/Net/src/WebSocketImpl.cpp @@ -47,7 +47,9 @@ WebSocketImpl::WebSocketImpl(StreamSocketImpl* pStreamSocketImpl, HTTPSession& s // for small WebSocket frames. Skip for Unix domain sockets. try { +#if defined(POCO_HAS_UNIX_SOCKET) if (_pStreamSocketImpl->address().family() != SocketAddress::UNIX_LOCAL) +#endif _pStreamSocketImpl->setNoDelay(true); } catch (NetException&)