From 5db7d2ca0aa51ff25f97bf21ce0cbc9e6b741cbd Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Tue, 5 Jul 2022 12:15:59 +0200 Subject: [PATCH] moveonly: move IsSelectableSocket() from compat.h to sock.{h,cpp} To be converted to a method of the `Sock` class. --- src/compat/compat.h | 8 -------- src/util/sock.cpp | 8 ++++++++ src/util/sock.h | 2 ++ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/compat/compat.h b/src/compat/compat.h index a8e5552c0ad..cc377975771 100644 --- a/src/compat/compat.h +++ b/src/compat/compat.h @@ -109,14 +109,6 @@ typedef char* sockopt_arg_type; #define USE_POLL #endif -bool static inline IsSelectableSocket(const SOCKET& s) { -#if defined(USE_POLL) || defined(WIN32) - return true; -#else - return (s < FD_SETSIZE); -#endif -} - // MSG_NOSIGNAL is not available on some platforms, if it doesn't exist define it as 0 #if !defined(MSG_NOSIGNAL) #define MSG_NOSIGNAL 0 diff --git a/src/util/sock.cpp b/src/util/sock.cpp index 125dbc7f187..fed50444a97 100644 --- a/src/util/sock.cpp +++ b/src/util/sock.cpp @@ -117,6 +117,14 @@ int Sock::GetSockName(sockaddr* name, socklen_t* name_len) const return getsockname(m_socket, name, name_len); } +bool IsSelectableSocket(const SOCKET& s) { +#if defined(USE_POLL) || defined(WIN32) + return true; +#else + return (s < FD_SETSIZE); +#endif +} + bool Sock::Wait(std::chrono::milliseconds timeout, Event requested, Event* occurred) const { // We need a `shared_ptr` owning `this` for `WaitMany()`, but don't want diff --git a/src/util/sock.h b/src/util/sock.h index 38a7dc80d6f..9ec53ec91d1 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -267,6 +267,8 @@ private: void Close(); }; +bool IsSelectableSocket(const SOCKET& s); + /** Return readable error string for a network error code */ std::string NetworkErrorString(int err);