aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorVasil Dimov <vd@FreeBSD.org>2021-02-12 15:56:15 +0100
committerVasil Dimov <vd@FreeBSD.org>2021-03-01 13:22:17 +0100
commit78fdfbea666201b25919dd67454eb04d6a34326f (patch)
tree95fd390aa3d5666b17e7895c8a7f0b5d0bc138d8 /src
parent34bcfab562bac9887ca9c3831cf4fd0ee7f98149 (diff)
downloadbitcoin-78fdfbea666201b25919dd67454eb04d6a34326f.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/compat.h10
-rw-r--r--src/net.cpp11
-rw-r--r--src/netbase.cpp5
3 files changed, 12 insertions, 14 deletions
diff --git a/src/compat.h b/src/compat.h
index dad14748a2..640be23546 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 d03e3cac37..89f7ef0f06 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -11,6 +11,7 @@
#include <banman.h>
#include <clientversion.h>
+#include <compat.h>
#include <consensus/consensus.h>
#include <crypto/sha256.h>
#include <net_permissions.h>
@@ -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 5a714f0026..7ccd24a778 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -5,6 +5,7 @@
#include <netbase.h>
+#include <compat.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/sock.h>
@@ -30,10 +31,6 @@
#include <poll.h>
#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);