aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorPatrick Strateman <patrick.strateman@gmail.com>2018-10-29 16:30:30 -0400
committerPatrick Strateman <patrick.strateman@gmail.com>2018-11-30 18:02:51 -0500
commit1e6afd0dbc1c581435588e1e9bb419a035b81028 (patch)
treef6ef21aa0377eb4d9112060056675a18e8e7e8c1 /src/net.cpp
parent011c42c5bd175e14b03741398f5d4f8a4cf3dee5 (diff)
Introduce and use constant SELECT_TIMEOUT_MILLISECONDS.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/net.cpp b/src/net.cpp
index b85a8c2c1d..0613e05998 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -71,6 +71,10 @@ enum BindFlags {
BF_WHITELIST = (1U << 2),
};
+// The set of sockets cannot be modified while waiting
+// The sleep time needs to be small to avoid new sockets stalling
+static const uint64_t SELECT_TIMEOUT_MILLISECONDS = 50;
+
const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*";
static const uint64_t RANDOMIZER_ID_NETGROUP = 0x6c0edd8036ef4036ULL; // SHA256("netgroup")[0:8]
@@ -1264,7 +1268,7 @@ void CConnman::SocketHandler()
//
struct timeval timeout;
timeout.tv_sec = 0;
- timeout.tv_usec = 50000; // frequency to poll pnode->vSend
+ timeout.tv_usec = SELECT_TIMEOUT_MILLISECONDS * 1000; // frequency to poll pnode->vSend
fd_set fdsetRecv;
fd_set fdsetSend;
@@ -1337,7 +1341,7 @@ void CConnman::SocketHandler()
}
FD_ZERO(&fdsetSend);
FD_ZERO(&fdsetError);
- if (!interruptNet.sleep_for(std::chrono::milliseconds(timeout.tv_usec/1000)))
+ if (!interruptNet.sleep_for(std::chrono::milliseconds(SELECT_TIMEOUT_MILLISECONDS)))
return;
}