mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Merge #9289: net: drop boost::thread_group
67ee4ecnet: misc header cleanups (Cory Fields)8b3159enet: make proxy receives interruptible (Cory Fields)5cb0fcenet: remove thread_interrupted catch (Cory Fields)d3d7056net: make net processing interruptible (Cory Fields)0985052net: make net interruptible (Cory Fields)799df91net: add CThreadInterrupt and InterruptibleSleep (Cory Fields)7325b15net: a few small cleanups before replacing boost threads (Cory Fields)
This commit is contained in:
@@ -16,20 +16,14 @@
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#ifdef HAVE_GETADDRINFO_A
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
#include <atomic>
|
||||
|
||||
#ifndef WIN32
|
||||
#if HAVE_INET_PTON
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include <boost/algorithm/string/case_conv.hpp> // for to_lower()
|
||||
#include <boost/algorithm/string/predicate.hpp> // for startswith() and endswith()
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
|
||||
#define MSG_NOSIGNAL 0
|
||||
@@ -44,6 +38,7 @@ bool fNameLookup = DEFAULT_NAME_LOOKUP;
|
||||
|
||||
// Need ample time for negotiation for very slow proxies such as Tor (milliseconds)
|
||||
static const int SOCKS5_RECV_TIMEOUT = 20 * 1000;
|
||||
static std::atomic<bool> interruptSocks5Recv(false);
|
||||
|
||||
enum Network ParseNetwork(std::string net) {
|
||||
boost::to_lower(net);
|
||||
@@ -206,7 +201,7 @@ struct timeval MillisToTimeval(int64_t nTimeout)
|
||||
/**
|
||||
* Read bytes from socket. This will either read the full number of bytes requested
|
||||
* or return False on error or timeout.
|
||||
* This function can be interrupted by boost thread interrupt.
|
||||
* This function can be interrupted by calling InterruptSocks5()
|
||||
*
|
||||
* @param data Buffer to receive into
|
||||
* @param len Length of data to receive
|
||||
@@ -246,7 +241,8 @@ bool static InterruptibleRecv(char* data, size_t len, int timeout, SOCKET& hSock
|
||||
return false;
|
||||
}
|
||||
}
|
||||
boost::this_thread::interruption_point();
|
||||
if (interruptSocks5Recv)
|
||||
return false;
|
||||
curTime = GetTimeMillis();
|
||||
}
|
||||
return len == 0;
|
||||
@@ -715,3 +711,8 @@ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void InterruptSocks5(bool interrupt)
|
||||
{
|
||||
interruptSocks5Recv = interrupt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user