From 78fdfbea666201b25919dd67454eb04d6a34326f Mon Sep 17 00:00:00 2001 From: Vasil Dimov Date: Fri, 12 Feb 2021 15:56:15 +0100 Subject: [PATCH] net: dedup MSG_NOSIGNAL and MSG_DONTWAIT definitions Deduplicate `MSG_NOSIGNAL` and `MSG_DONTWAIT` definitions from `net.cpp` and `netbase.cpp` to `compat.h` where they can also be reused by other code. --- src/compat.h | 10 ++++++++++ src/net.cpp | 11 +---------- src/netbase.cpp | 5 +---- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/compat.h b/src/compat.h index dad14748a2e..640be235462 100644 --- a/src/compat.h +++ b/src/compat.h @@ -96,4 +96,14 @@ bool static inline IsSelectableSocket(const SOCKET& s) { #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 +#endif + +// MSG_DONTWAIT is not available on some platforms, if it doesn't exist define it as 0 +#if !defined(MSG_DONTWAIT) +#define MSG_DONTWAIT 0 +#endif + #endif // BITCOIN_COMPAT_H diff --git a/src/net.cpp b/src/net.cpp index d03e3cac37f..89f7ef0f064 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -72,16 +73,6 @@ static constexpr std::chrono::seconds MAX_UPLOAD_TIMEFRAME{60 * 60 * 24}; // We add a random period time (0 to 1 seconds) to feeler connections to prevent synchronization. #define FEELER_SLEEP_WINDOW 1 -// 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 -#endif - -// MSG_DONTWAIT is not available on some platforms, if it doesn't exist define it as 0 -#if !defined(MSG_DONTWAIT) -#define MSG_DONTWAIT 0 -#endif - /** Used to pass flags to the Bind() function */ enum BindFlags { BF_NONE = 0, diff --git a/src/netbase.cpp b/src/netbase.cpp index 5a714f00260..7ccd24a7789 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -5,6 +5,7 @@ #include +#include #include #include #include @@ -30,10 +31,6 @@ #include #endif -#if !defined(MSG_NOSIGNAL) -#define MSG_NOSIGNAL 0 -#endif - // Settings static Mutex g_proxyinfo_mutex; static proxyType proxyInfo[NET_MAX] GUARDED_BY(g_proxyinfo_mutex);