Browse Source

Merge pull request #1844 from subtly/discovery

Prevent socket from closing due to attempt to send to bad address.
cl-refactor
Gav Wood 10 years ago
parent
commit
2c59a06a3d
  1. 9
      libp2p/UDP.h

9
libp2p/UDP.h

@ -223,9 +223,14 @@ void UDPSocket<Handler, MaxDatagramSize>::doWrite()
const UDPDatagram& datagram = m_sendQ[0];
auto self(UDPSocket<Handler, MaxDatagramSize>::shared_from_this());
m_socket.async_send_to(boost::asio::buffer(datagram.data), datagram.endpoint(), [this, self](boost::system::error_code _ec, std::size_t)
bi::udp::endpoint endpoint(datagram.endpoint());
m_socket.async_send_to(boost::asio::buffer(datagram.data), endpoint, [this, self, endpoint](boost::system::error_code _ec, std::size_t)
{
if (_ec || m_closed)
if (m_closed)
return disconnectWithError(_ec);
else if (_ec != boost::system::errc::success &&
_ec != boost::system::errc::address_not_available &&
_ec != boost::system::errc::host_unreachable)
return disconnectWithError(_ec);
else
{

Loading…
Cancel
Save