Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 1,224 Lines • ▼ Show 20 Lines | void CConnman::AcceptConnection(const ListenSocket &hListenSocket) { | ||||
LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString()); | LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString()); | ||||
{ | { | ||||
LOCK(cs_vNodes); | LOCK(cs_vNodes); | ||||
vNodes.push_back(pnode); | vNodes.push_back(pnode); | ||||
} | } | ||||
} | } | ||||
void CConnman::NotifyNumConnectionsChanged() { | |||||
size_t vNodesSize; | |||||
{ | |||||
LOCK(cs_vNodes); | |||||
vNodesSize = vNodes.size(); | |||||
} | |||||
if (vNodesSize != nPrevNodeCount) { | |||||
nPrevNodeCount = vNodesSize; | |||||
if (clientInterface) { | |||||
clientInterface->NotifyNumConnectionsChanged(vNodesSize); | |||||
} | |||||
} | |||||
} | |||||
void CConnman::ThreadSocketHandler() { | void CConnman::ThreadSocketHandler() { | ||||
unsigned int nPrevNodeCount = 0; | |||||
while (!interruptNet) { | while (!interruptNet) { | ||||
// | // | ||||
// Disconnect nodes | // Disconnect nodes | ||||
// | // | ||||
{ | { | ||||
LOCK(cs_vNodes); | LOCK(cs_vNodes); | ||||
if (!fNetworkActive) { | if (!fNetworkActive) { | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | while (!interruptNet) { | ||||
} | } | ||||
if (fDelete) { | if (fDelete) { | ||||
vNodesDisconnected.remove(pnode); | vNodesDisconnected.remove(pnode); | ||||
DeleteNode(pnode); | DeleteNode(pnode); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
size_t vNodesSize; | NotifyNumConnectionsChanged(); | ||||
{ | |||||
LOCK(cs_vNodes); | |||||
vNodesSize = vNodes.size(); | |||||
} | |||||
if (vNodesSize != nPrevNodeCount) { | |||||
nPrevNodeCount = vNodesSize; | |||||
if (clientInterface) { | |||||
clientInterface->NotifyNumConnectionsChanged(nPrevNodeCount); | |||||
} | |||||
} | |||||
// | // | ||||
// Find which sockets have data to receive | // Find which sockets have data to receive | ||||
// | // | ||||
struct timeval timeout; | struct timeval timeout; | ||||
timeout.tv_sec = 0; | timeout.tv_sec = 0; | ||||
// Frequency to poll pnode->vSend | // Frequency to poll pnode->vSend | ||||
timeout.tv_usec = 50000; | timeout.tv_usec = 50000; | ||||
▲ Show 20 Lines • Show All 1,026 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
CConnman::CConnman(const Config &configIn, uint64_t nSeed0In, uint64_t nSeed1In) | CConnman::CConnman(const Config &configIn, uint64_t nSeed0In, uint64_t nSeed1In) | ||||
: config(&configIn), nSeed0(nSeed0In), nSeed1(nSeed1In) { | : config(&configIn), nSeed0(nSeed0In), nSeed1(nSeed1In) { | ||||
fNetworkActive = true; | fNetworkActive = true; | ||||
setBannedIsDirty = false; | setBannedIsDirty = false; | ||||
fAddressesInitialized = false; | fAddressesInitialized = false; | ||||
nLastNodeId = 0; | nLastNodeId = 0; | ||||
nPrevNodeCount = 0; | |||||
nSendBufferMaxSize = 0; | nSendBufferMaxSize = 0; | ||||
nReceiveFloodSize = 0; | nReceiveFloodSize = 0; | ||||
flagInterruptMsgProc = false; | flagInterruptMsgProc = false; | ||||
SetTryNewOutboundPeer(false); | SetTryNewOutboundPeer(false); | ||||
Options connOptions; | Options connOptions; | ||||
Init(connOptions); | Init(connOptions); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 760 Lines • Show Last 20 Lines |