|
|
@ -203,7 +203,10 @@ void UDPSocket<Handler, MaxDatagramSize>::doRead() |
|
|
|
auto self(UDPSocket<Handler, MaxDatagramSize>::shared_from_this()); |
|
|
|
m_socket.async_receive_from(boost::asio::buffer(m_recvData), m_recvEndpoint, [this, self](boost::system::error_code _ec, size_t _len) |
|
|
|
{ |
|
|
|
if (_ec) |
|
|
|
// ASIO Safety: It is possible that ASIO will call lambda w/o an error
|
|
|
|
// and after the socket has been disconnected. Checking m_closed
|
|
|
|
// guarantees that m_host will not be called after disconnect().
|
|
|
|
if (_ec || m_closed) |
|
|
|
return disconnectWithError(_ec); |
|
|
|
|
|
|
|
assert(_len); |
|
|
@ -222,7 +225,7 @@ void UDPSocket<Handler, MaxDatagramSize>::doWrite() |
|
|
|
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) |
|
|
|
{ |
|
|
|
if (_ec) |
|
|
|
if (_ec || m_closed) |
|
|
|
return disconnectWithError(_ec); |
|
|
|
else |
|
|
|
{ |
|
|
|