mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
Use unique_ptr for sem{Addnode,Outbound} (CSemaphore)
This commit is contained in:
parent
73db0635a3
commit
8ccf1bb0c3
12
src/net.cpp
12
src/net.cpp
@ -2222,8 +2222,6 @@ CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In) : nSeed0(nSeed0In), nSe
|
||||
nLastNodeId = 0;
|
||||
nSendBufferMaxSize = 0;
|
||||
nReceiveFloodSize = 0;
|
||||
semOutbound = nullptr;
|
||||
semAddnode = nullptr;
|
||||
flagInterruptMsgProc = false;
|
||||
SetTryNewOutboundPeer(false);
|
||||
|
||||
@ -2329,11 +2327,11 @@ bool CConnman::Start(CScheduler& scheduler, const Options& connOptions)
|
||||
|
||||
if (semOutbound == nullptr) {
|
||||
// initialize semaphore
|
||||
semOutbound = new CSemaphore(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections));
|
||||
semOutbound = std::unique_ptr<CSemaphore>(new CSemaphore(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections)));
|
||||
}
|
||||
if (semAddnode == nullptr) {
|
||||
// initialize semaphore
|
||||
semAddnode = new CSemaphore(nMaxAddnode);
|
||||
semAddnode = std::unique_ptr<CSemaphore>(new CSemaphore(nMaxAddnode));
|
||||
}
|
||||
|
||||
//
|
||||
@ -2456,10 +2454,8 @@ void CConnman::Stop()
|
||||
vNodes.clear();
|
||||
vNodesDisconnected.clear();
|
||||
vhListenSocket.clear();
|
||||
delete semOutbound;
|
||||
semOutbound = nullptr;
|
||||
delete semAddnode;
|
||||
semAddnode = nullptr;
|
||||
semOutbound.reset();
|
||||
semAddnode.reset();
|
||||
}
|
||||
|
||||
void CConnman::DeleteNode(CNode* pnode)
|
||||
|
@ -399,8 +399,8 @@ private:
|
||||
/** Services this instance offers */
|
||||
ServiceFlags nLocalServices;
|
||||
|
||||
CSemaphore *semOutbound;
|
||||
CSemaphore *semAddnode;
|
||||
std::unique_ptr<CSemaphore> semOutbound;
|
||||
std::unique_ptr<CSemaphore> semAddnode;
|
||||
int nMaxConnections;
|
||||
int nMaxOutbound;
|
||||
int nMaxAddnode;
|
||||
|
Loading…
Reference in New Issue
Block a user