Browse Source

Slightly more error resistant.

cl-refactor
Gav Wood 11 years ago
parent
commit
69aed5087e
  1. 10
      libethereum/PeerNetwork.cpp

10
libethereum/PeerNetwork.cpp

@ -340,6 +340,8 @@ void PeerSession::doRead()
if (ec) if (ec)
dropped(); dropped();
else else
{
try
{ {
m_incoming.resize(m_incoming.size() + length); m_incoming.resize(m_incoming.size() + length);
memcpy(m_incoming.data() + m_incoming.size() - length, m_data.data(), length); memcpy(m_incoming.data() + m_incoming.size() - length, m_data.data(), length);
@ -354,7 +356,7 @@ void PeerSession::doRead()
else else
{ {
uint32_t len = fromBigEndian<uint32_t>(bytesConstRef(m_incoming.data() + 4, 4)); uint32_t len = fromBigEndian<uint32_t>(bytesConstRef(m_incoming.data() + 4, 4));
// cout << "Received packet of " << len << " bytes" << endl; // cout << "Received packet of " << len << " bytes" << endl;
if (m_incoming.size() - 8 < len) if (m_incoming.size() - 8 < len)
break; break;
@ -369,6 +371,12 @@ void PeerSession::doRead()
} }
doRead(); doRead();
} }
catch (std::exception const& _e)
{
cout << std::setw(2) << m_socket.native_handle() << " | ERROR: " << _e.what() << endl;
dropped();
}
}
}); });
} }

Loading…
Cancel
Save