Browse Source

UDP Client: ignore incomming traffic and error when stopping (prevent socket restarting)

Signed-off-by: R4SAS <r4sas@i2pmail.org>
pull/1752/head
R4SAS 3 years ago
parent
commit
b7e7c6db7b
Signed by: r4sas
GPG Key ID: 66F6C87B98EBCFE2
  1. 7
      libi2pd_client/I2PTunnel.cpp

7
libi2pd_client/I2PTunnel.cpp

@ -991,6 +991,10 @@ namespace client
void I2PUDPClientTunnel::HandleRecvFromLocal(const boost::system::error_code & ec, std::size_t transferred) void I2PUDPClientTunnel::HandleRecvFromLocal(const boost::system::error_code & ec, std::size_t transferred)
{ {
if(m_cancel_resolve) {
LogPrint(eLogDebug, "UDP Client: Ignoring incomming data: stoppping");
return;
}
if(ec) { if(ec) {
LogPrint(eLogError, "UDP Client: Reading from socket error: ", ec.message(), ". Restarting listener..."); LogPrint(eLogError, "UDP Client: Reading from socket error: ", ec.message(), ". Restarting listener...");
RecvFromLocal(); // Restart listener and continue work RecvFromLocal(); // Restart listener and continue work
@ -1107,14 +1111,13 @@ namespace client
{ {
auto dgram = m_LocalDest->GetDatagramDestination(); auto dgram = m_LocalDest->GetDatagramDestination();
if (dgram) dgram->ResetReceiver(); if (dgram) dgram->ResetReceiver();
m_cancel_resolve = true;
m_Sessions.clear(); m_Sessions.clear();
if(m_LocalSocket.is_open()) if(m_LocalSocket.is_open())
m_LocalSocket.close(); m_LocalSocket.close();
m_cancel_resolve = true;
if(m_ResolveThread) if(m_ResolveThread)
{ {
m_ResolveThread->join(); m_ResolveThread->join();

Loading…
Cancel
Save