aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorlaanwj <126646+laanwj@users.noreply.github.com>2022-04-14 10:05:00 +0200
committerlaanwj <126646+laanwj@users.noreply.github.com>2022-04-14 10:16:01 +0200
commitb69fd5eaa99f84b62a49d7c7f48d8cee1227592a (patch)
tree641d5074bc900c6ca831336838013d7c055e7f61 /src/netbase.cpp
parent1e3ed01faa77215a7c36308237280aaa58895532 (diff)
parentc71117fcb04fc2e45b5e76fe96b077a07b0c0f82 (diff)
downloadbitcoin-b69fd5eaa99f84b62a49d7c7f48d8cee1227592a.tar.xz
Merge bitcoin/bitcoin#22052: net: remove non-blocking bool from interface
c71117fcb04fc2e45b5e76fe96b077a07b0c0f82 net: remove non-blocking bool from interface (Bushstar) Pull request description: SetSocketNonBlocking was added in 0.11 in the PR below with a second argument to toggle non-blocking mode for the socket. That argument has always been set to true in all subsequent releases and I'm not sure why it is present. https://github.com/bitcoin/bitcoin/pull/4491 ACKs for top commit: promag: Code review ACK c71117fcb04fc2e45b5e76fe96b077a07b0c0f82. lsilva01: Code review ACK https://github.com/bitcoin/bitcoin/pull/22052/commits/c71117fcb04fc2e45b5e76fe96b077a07b0c0f82 vasild: ACK c71117fcb04fc2e45b5e76fe96b077a07b0c0f82 Tree-SHA512: feebfcfa75d997460a0ba42ffe1e0c25a7e0bfcad12510ad73ea4942cc1c653f9ad429adbbb00b9288fe319009552906fcb635a14dfd7dcbde3853baab6be065
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 9a0b800565..e6d4f16ba0 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -305,7 +305,7 @@ enum class IntrRecvError {
*
* @see This function can be interrupted by calling InterruptSocks5(bool).
* Sockets can be made non-blocking with SetSocketNonBlocking(const
- * SOCKET&, bool).
+ * SOCKET&).
*/
static IntrRecvError InterruptibleRecv(uint8_t* data, size_t len, int timeout, const Sock& sock)
{
@@ -518,7 +518,7 @@ std::unique_ptr<Sock> CreateSockTCP(const CService& address_family)
SetSocketNoDelay(hSocket);
// Set the non-blocking option on the socket.
- if (!SetSocketNonBlocking(hSocket, true)) {
+ if (!SetSocketNonBlocking(hSocket)) {
CloseSocket(hSocket);
LogPrintf("Error setting socket to non-blocking: %s\n", NetworkErrorString(WSAGetLastError()));
return nullptr;
@@ -711,28 +711,16 @@ bool LookupSubNet(const std::string& subnet_str, CSubNet& subnet_out)
return false;
}
-bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking)
+bool SetSocketNonBlocking(const SOCKET& hSocket)
{
- if (fNonBlocking) {
#ifdef WIN32
- u_long nOne = 1;
- if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
+ u_long nOne = 1;
+ if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
#else
- int fFlags = fcntl(hSocket, F_GETFL, 0);
- if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == SOCKET_ERROR) {
+ int fFlags = fcntl(hSocket, F_GETFL, 0);
+ if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == SOCKET_ERROR) {
#endif
- return false;
- }
- } else {
-#ifdef WIN32
- u_long nZero = 0;
- if (ioctlsocket(hSocket, FIONBIO, &nZero) == SOCKET_ERROR) {
-#else
- int fFlags = fcntl(hSocket, F_GETFL, 0);
- if (fcntl(hSocket, F_SETFL, fFlags & ~O_NONBLOCK) == SOCKET_ERROR) {
-#endif
- return false;
- }
+ return false;
}
return true;