Skip to content

Commit

Permalink
Node: crash fix (fix of fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
valdok committed Jan 3, 2019
1 parent d9d1205 commit 2cdab2a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,15 +1183,16 @@ void Node::Peer::OnMsg(proto::Authentication&& msg)
// Duplicate connection. In this case we have to choose wether to terminate this connection, or the previous. The best is to do it asymmetrically.
// We decide this based on our Node IDs.
// In addition, if the older connection isn't completed yet (i.e. it's our connect attempt) - it's prefered for deletion, because such a connection may be impossible (firewalls and friends).
Peer* pDup = pPi->m_pLive;

if (!pPi->m_pLive->IsSecureOut() || (m_This.m_MyPublicID > msg.m_ID))
if (!pDup->IsSecureOut() || (m_This.m_MyPublicID > msg.m_ID))
{
// detach from that peer
assert(pPi == pPi->m_pLive->m_pInfo);
pPi->m_pLive->m_pInfo = nullptr;
assert(pPi == pDup->m_pInfo);
pDup->m_pInfo = nullptr;
pPi->m_pLive = nullptr;

pPi->m_pLive->DeleteSelf(false, ByeReason::Duplicate);
pDup->DeleteSelf(false, ByeReason::Duplicate);
assert(!pPi->m_pLive);
}
else
Expand Down

0 comments on commit 2cdab2a

Please sign in to comment.