From b7e7c6db7bfbbbd9be83eeb96873d8935e305f6d Mon Sep 17 00:00:00 2001 From: R4SAS Date: Sun, 10 Apr 2022 23:10:16 +0300 Subject: [PATCH] UDP Client: ignore incomming traffic and error when stopping (prevent socket restarting) Signed-off-by: R4SAS --- libi2pd_client/I2PTunnel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libi2pd_client/I2PTunnel.cpp b/libi2pd_client/I2PTunnel.cpp index afb13a18..17a5f166 100644 --- a/libi2pd_client/I2PTunnel.cpp +++ b/libi2pd_client/I2PTunnel.cpp @@ -991,6 +991,10 @@ namespace client 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) { LogPrint(eLogError, "UDP Client: Reading from socket error: ", ec.message(), ". Restarting listener..."); RecvFromLocal(); // Restart listener and continue work @@ -1107,14 +1111,13 @@ namespace client { auto dgram = m_LocalDest->GetDatagramDestination(); if (dgram) dgram->ResetReceiver(); + m_cancel_resolve = true; m_Sessions.clear(); if(m_LocalSocket.is_open()) m_LocalSocket.close(); - m_cancel_resolve = true; - if(m_ResolveThread) { m_ResolveThread->join();