mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 22:18:54 +01:00
net: remove non-blocking bool from interface
This commit is contained in:
@@ -304,7 +304,7 @@ enum class IntrRecvError {
|
|||||||
*
|
*
|
||||||
* @see This function can be interrupted by calling InterruptSocks5(bool).
|
* @see This function can be interrupted by calling InterruptSocks5(bool).
|
||||||
* Sockets can be made non-blocking with SetSocketNonBlocking(const
|
* 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)
|
static IntrRecvError InterruptibleRecv(uint8_t* data, size_t len, int timeout, const Sock& sock)
|
||||||
{
|
{
|
||||||
@@ -517,7 +517,7 @@ std::unique_ptr<Sock> CreateSockTCP(const CService& address_family)
|
|||||||
SetSocketNoDelay(hSocket);
|
SetSocketNoDelay(hSocket);
|
||||||
|
|
||||||
// Set the non-blocking option on the socket.
|
// Set the non-blocking option on the socket.
|
||||||
if (!SetSocketNonBlocking(hSocket, true)) {
|
if (!SetSocketNonBlocking(hSocket)) {
|
||||||
CloseSocket(hSocket);
|
CloseSocket(hSocket);
|
||||||
LogPrintf("Error setting socket to non-blocking: %s\n", NetworkErrorString(WSAGetLastError()));
|
LogPrintf("Error setting socket to non-blocking: %s\n", NetworkErrorString(WSAGetLastError()));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -716,9 +716,8 @@ bool LookupSubNet(const std::string& strSubnet, CSubNet& ret, DNSLookupFn dns_lo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking)
|
bool SetSocketNonBlocking(const SOCKET& hSocket)
|
||||||
{
|
{
|
||||||
if (fNonBlocking) {
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
u_long nOne = 1;
|
u_long nOne = 1;
|
||||||
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
|
if (ioctlsocket(hSocket, FIONBIO, &nOne) == SOCKET_ERROR) {
|
||||||
@@ -728,17 +727,6 @@ bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking)
|
|||||||
#endif
|
#endif
|
||||||
return false;
|
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 true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,8 +220,8 @@ bool ConnectSocketDirectly(const CService &addrConnect, const Sock& sock, int nT
|
|||||||
*/
|
*/
|
||||||
bool ConnectThroughProxy(const proxyType& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed);
|
bool ConnectThroughProxy(const proxyType& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed);
|
||||||
|
|
||||||
/** Disable or enable blocking-mode for a socket */
|
/** Enable non-blocking mode for a socket */
|
||||||
bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking);
|
bool SetSocketNonBlocking(const SOCKET& hSocket);
|
||||||
/** Set the TCP_NODELAY flag on a socket */
|
/** Set the TCP_NODELAY flag on a socket */
|
||||||
bool SetSocketNoDelay(const SOCKET& hSocket);
|
bool SetSocketNoDelay(const SOCKET& hSocket);
|
||||||
void InterruptSocks5(bool interrupt);
|
void InterruptSocks5(bool interrupt);
|
||||||
|
|||||||
Reference in New Issue
Block a user