aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-12-27 17:13:31 -0500
committerCory Fields <cory-nospam-@coryfields.com>2017-01-03 17:56:21 -0500
commit8b3159ef0a912da67c545a3d24f4558f8df866e4 (patch)
treed98a7bc50b3b21faec735afd103d34ca22b54936 /src/netbase.cpp
parent5cb0fcee8137d6de8d2b9525aa45fd11ab2231c8 (diff)
net: make proxy receives interruptible
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index da94fd4d13..87c7abd7c1 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -19,6 +19,7 @@
#ifdef HAVE_GETADDRINFO_A
#include <netdb.h>
#endif
+#include <atomic>
#ifndef WIN32
#if HAVE_INET_PTON
@@ -44,6 +45,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 +208,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 +248,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 +718,8 @@ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking)
return true;
}
+
+void InterruptSocks5(bool interrupt)
+{
+ interruptSocks5Recv = interrupt;
+}