Skip to content

Commit

Permalink
net: dedup MSG_NOSIGNAL and MSG_DONTWAIT definitions
Browse files Browse the repository at this point in the history
Summary:
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.

This is a backport of [[bitcoin/bitcoin#20685 | [[bitcoin/bitcoin#20685 | core#20685]]]] [10/20]
bitcoin/bitcoin@78fdfbe

Depends on D11018

Test Plan:
`ninja all check-all`

eviewers:

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D11019
  • Loading branch information
vasild authored and PiRK committed Feb 11, 2022
1 parent aff7e41 commit 60329d3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
12 changes: 12 additions & 0 deletions src/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,16 @@ static bool 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
13 changes: 1 addition & 12 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <avalanche/avalanche.h>
#include <banman.h>
#include <clientversion.h>
#include <compat.h>
#include <config.h>
#include <consensus/consensus.h>
#include <crypto/sha256.h>
Expand Down Expand Up @@ -92,18 +93,6 @@ static constexpr std::chrono::seconds MAX_UPLOAD_TIMEFRAME{60 * 60 * 24};
// 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,
Expand Down
5 changes: 1 addition & 4 deletions src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <netbase.h>

#include <compat.h>
#include <sync.h>
#include <tinyformat.h>
#include <util/sock.h>
Expand All @@ -29,10 +30,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);
Expand Down

0 comments on commit 60329d3

Please sign in to comment.