Browse Source

Merge pull request #1515 from ethereum/p2p

Fix crash accessing nullptr.
cl-refactor
Gav Wood 10 years ago
parent
commit
c8f7c12627
  1. 9
      libp2p/Host.cpp
  2. 2
      libwhisper/WhisperHost.cpp

9
libp2p/Host.cpp

@ -217,9 +217,8 @@ void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io
ps->disconnect(DuplicatePeer); ps->disconnect(DuplicatePeer);
return; return;
} }
m_sessions[_id] = ps;
} // todo: mutex Session::m_capabilities and move for(:caps) out of mutex.
ps->start();
unsigned o = (unsigned)UserPacket; unsigned o = (unsigned)UserPacket;
for (auto const& i: caps) for (auto const& i: caps)
if (haveCapability(i)) if (haveCapability(i))
@ -227,6 +226,10 @@ void Host::startPeerSession(Public const& _id, RLP const& _rlp, RLPXFrameIO* _io
ps->m_capabilities[i] = shared_ptr<Capability>(m_capabilities[i]->newPeerCapability(ps.get(), o)); ps->m_capabilities[i] = shared_ptr<Capability>(m_capabilities[i]->newPeerCapability(ps.get(), o));
o += m_capabilities[i]->messageCount(); o += m_capabilities[i]->messageCount();
} }
ps->start();
m_sessions[_id] = ps;
}
clog(NetNote) << "p2p.host.peer.register" << _id.abridged(); clog(NetNote) << "p2p.host.peer.register" << _id.abridged();
StructuredLogger::p2pConnected(_id.abridged(), ps->m_peer->peerEndpoint(), ps->m_peer->m_lastConnected, clientVersion, peerCount()); StructuredLogger::p2pConnected(_id.abridged(), ps->m_peer->peerEndpoint(), ps->m_peer->m_lastConnected, clientVersion, peerCount());
} }

2
libwhisper/WhisperHost.cpp

@ -162,7 +162,7 @@ void WhisperHost::uninstallWatch(unsigned _i)
void WhisperHost::doWork() void WhisperHost::doWork()
{ {
for (auto& i: peerSessions()) for (auto i: peerSessions())
i.first->cap<WhisperPeer>().get()->sendMessages(); i.first->cap<WhisperPeer>().get()->sendMessages();
cleanup(); cleanup();
} }

Loading…
Cancel
Save