mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge #9441: Net: Massive speedup. Net locks overhaul
e60360enet: remove cs_vRecvMsg (Cory Fields)991955enet: add a flag to indicate when a node's send buffer is full (Cory Fields)c6e8a9bnet: add a flag to indicate when a node's process queue is full (Cory Fields)4d712e3net: add a new message queue for the message processor (Cory Fields)c5a8b1bnet: rework the way that the messagehandler sleeps (Cory Fields)c72cc88net: remove useless comments (Cory Fields)ef7b5ecnet: Add a simple function for waking the message handler (Cory Fields)f5c36d1net: record bytes written before notifying the message processor (Cory Fields)60befa3net: handle message accounting in ReceiveMsgBytes (Cory Fields)56212e2net: set message deserialization version when it's actually time to deserialize (Cory Fields)0e973d9net: remove redundant max sendbuffer size check (Cory Fields)6042587net: wait until the node is destroyed to delete its recv buffer (Cory Fields)f6315e0net: only disconnect if fDisconnect has been set (Cory Fields)5b4a8acnet: make GetReceiveFloodSize public (Cory Fields)e5bcd9cnet: make vRecvMsg a list so that we can use splice() (Cory Fields)53ad9a1net: fix typo causing the wrong receive buffer size (Cory Fields)
This commit is contained in:
38
src/net.h
38
src/net.h
@@ -327,6 +327,7 @@ public:
|
||||
/** Get a unique deterministic randomizer. */
|
||||
CSipHasher GetDeterministicRandomizer(uint64_t id);
|
||||
|
||||
unsigned int GetReceiveFloodSize() const;
|
||||
private:
|
||||
struct ListenSocket {
|
||||
SOCKET socket;
|
||||
@@ -343,6 +344,8 @@ private:
|
||||
void ThreadSocketHandler();
|
||||
void ThreadDNSAddressSeed();
|
||||
|
||||
void WakeMessageHandler();
|
||||
|
||||
uint64_t CalculateKeyedNetGroup(const CAddress& ad);
|
||||
|
||||
CNode* FindNode(const CNetAddr& ip);
|
||||
@@ -358,6 +361,7 @@ private:
|
||||
|
||||
NodeId GetNewNodeId();
|
||||
|
||||
size_t SocketSendData(CNode *pnode);
|
||||
//!check is the banlist has unwritten changes
|
||||
bool BannedSetIsDirty();
|
||||
//!set the "dirty" flag for the banlist
|
||||
@@ -368,8 +372,6 @@ private:
|
||||
void DumpData();
|
||||
void DumpBanlist();
|
||||
|
||||
unsigned int GetReceiveFloodSize() const;
|
||||
|
||||
// Network stats
|
||||
void RecordBytesRecv(uint64_t bytes);
|
||||
void RecordBytesSent(uint64_t bytes);
|
||||
@@ -428,6 +430,9 @@ private:
|
||||
/** SipHasher seeds for deterministic randomness */
|
||||
const uint64_t nSeed0, nSeed1;
|
||||
|
||||
/** flag for waking the message processor. */
|
||||
bool fMsgProcWake;
|
||||
|
||||
std::condition_variable condMsgProc;
|
||||
std::mutex mutexMsgProc;
|
||||
std::atomic<bool> flagInterruptMsgProc;
|
||||
@@ -445,7 +450,6 @@ void Discover(boost::thread_group& threadGroup);
|
||||
void MapPort(bool fUseUPnP);
|
||||
unsigned short GetListenPort();
|
||||
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
|
||||
size_t SocketSendData(CNode *pnode);
|
||||
|
||||
struct CombinerAll
|
||||
{
|
||||
@@ -610,11 +614,13 @@ public:
|
||||
std::deque<std::vector<unsigned char>> vSendMsg;
|
||||
CCriticalSection cs_vSend;
|
||||
|
||||
CCriticalSection cs_vProcessMsg;
|
||||
std::list<CNetMessage> vProcessMsg;
|
||||
size_t nProcessQueueSize;
|
||||
|
||||
std::deque<CInv> vRecvGetData;
|
||||
std::deque<CNetMessage> vRecvMsg;
|
||||
CCriticalSection cs_vRecvMsg;
|
||||
uint64_t nRecvBytes;
|
||||
int nRecvVersion;
|
||||
std::atomic<int> nRecvVersion;
|
||||
|
||||
int64_t nLastSend;
|
||||
int64_t nLastRecv;
|
||||
@@ -650,6 +656,8 @@ public:
|
||||
const NodeId id;
|
||||
|
||||
const uint64_t nKeyedNetGroup;
|
||||
std::atomic_bool fPauseRecv;
|
||||
std::atomic_bool fPauseSend;
|
||||
protected:
|
||||
|
||||
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
||||
@@ -723,6 +731,7 @@ private:
|
||||
const ServiceFlags nLocalServices;
|
||||
const int nMyStartingHeight;
|
||||
int nSendVersion;
|
||||
std::list<CNetMessage> vRecvMsg; // Used only by SocketHandler thread
|
||||
public:
|
||||
|
||||
NodeId GetId() const {
|
||||
@@ -743,24 +752,15 @@ public:
|
||||
return nRefCount;
|
||||
}
|
||||
|
||||
// requires LOCK(cs_vRecvMsg)
|
||||
unsigned int GetTotalRecvSize()
|
||||
{
|
||||
unsigned int total = 0;
|
||||
BOOST_FOREACH(const CNetMessage &msg, vRecvMsg)
|
||||
total += msg.vRecv.size() + 24;
|
||||
return total;
|
||||
}
|
||||
|
||||
// requires LOCK(cs_vRecvMsg)
|
||||
bool ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete);
|
||||
|
||||
// requires LOCK(cs_vRecvMsg)
|
||||
void SetRecvVersion(int nVersionIn)
|
||||
{
|
||||
nRecvVersion = nVersionIn;
|
||||
BOOST_FOREACH(CNetMessage &msg, vRecvMsg)
|
||||
msg.SetVersion(nVersionIn);
|
||||
}
|
||||
int GetRecvVersion()
|
||||
{
|
||||
return nRecvVersion;
|
||||
}
|
||||
void SetSendVersion(int nVersionIn)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user