Skip to content

Commit c71117f

Browse files
committed
net: remove non-blocking bool from interface
1 parent b295395 commit c71117f

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

src/netbase.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ enum class IntrRecvError {
304304
*
305305
* @see This function can be interrupted by calling InterruptSocks5(bool).
306306
* Sockets can be made non-blocking with SetSocketNonBlocking(const
307-
* SOCKET&, bool).
307+
* SOCKET&).
308308
*/
309309
static IntrRecvError InterruptibleRecv(uint8_t* data, size_t len, int timeout, const Sock& sock)
310310
{
@@ -517,7 +517,7 @@ std::unique_ptr<Sock> CreateSockTCP(const CService& address_family)
517517
SetSocketNoDelay(hSocket);
518518

519519
// Set the non-blocking option on the socket.
520-
if (!SetSocketNonBlocking(hSocket, true)) {
520+
if (!SetSocketNonBlocking(hSocket)) {
521521
CloseSocket(hSocket);
522522
LogPrintf("Error setting socket to non-blocking: %s\n", NetworkErrorString(WSAGetLastError()));
523523
return nullptr;
@@ -716,28 +716,16 @@ bool LookupSubNet(const std::string& strSubnet, CSubNet& ret, DNSLookupFn dns_lo
716716
return false;
717717
}
718718

719-
bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking)
719+
bool SetSocketNonBlocking(const SOCKET& hSocket)
720720
{
721-
if (fNonBlocking) {
722721
#ifdef WIN32
723-
u_long nOne = 1;
724-
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
722+
u_long nOne = 1;
723+
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
725724
#else
726-
int fFlags = fcntl(hSocket, F_GETFL, 0);
727-
if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == SOCKET_ERROR) {
725+
int fFlags = fcntl(hSocket, F_GETFL, 0);
726+
if (fcntl(hSocket, F_SETFL, fFlags | O_NONBLOCK) == SOCKET_ERROR) {
728727
#endif
729-
return false;
730-
}
731-
} else {
732-
#ifdef WIN32
733-
u_long nZero = 0;
734-
if (ioctlsocket(hSocket, FIONBIO, &nZero) == SOCKET_ERROR) {
735-
#else
736-
int fFlags = fcntl(hSocket, F_GETFL, 0);
737-
if (fcntl(hSocket, F_SETFL, fFlags & ~O_NONBLOCK) == SOCKET_ERROR) {
738-
#endif
739-
return false;
740-
}
728+
return false;
741729
}
742730

743731
return true;

src/netbase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@ bool ConnectSocketDirectly(const CService &addrConnect, const Sock& sock, int nT
220220
*/
221221
bool ConnectThroughProxy(const proxyType& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed);
222222

223-
/** Disable or enable blocking-mode for a socket */
224-
bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking);
223+
/** Enable non-blocking mode for a socket */
224+
bool SetSocketNonBlocking(const SOCKET& hSocket);
225225
/** Set the TCP_NODELAY flag on a socket */
226226
bool SetSocketNoDelay(const SOCKET& hSocket);
227227
void InterruptSocks5(bool interrupt);

0 commit comments

Comments
 (0)