From 6aa07fff5f8ba74dda047e6be01134a3561e67d1 Mon Sep 17 00:00:00 2001 From: orignal Date: Sat, 10 Oct 2026 18:45:57 -0400 Subject: [PATCH] don't drop datagram right away if remote LeaseSet is being requested --- libi2pd/Datagram.cpp | 17 +++++++++++------ libi2pd/Datagram.h | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/libi2pd/Datagram.cpp b/libi2pd/Datagram.cpp index 9fb7776e..4ddb9be0 100644 --- a/libi2pd/Datagram.cpp +++ b/libi2pd/Datagram.cpp @@ -749,11 +749,14 @@ namespace datagram void DatagramSession::HandleLeaseSetUpdated(std::shared_ptr ls) { m_RequestingLS = false; - if(!ls) return; - // only update lease set if found and newer than previous lease set - uint64_t oldExpire = 0; - if(m_RemoteLeaseSet) oldExpire = m_RemoteLeaseSet->GetExpirationTime(); - if(ls && ls->GetExpirationTime() > oldExpire) m_RemoteLeaseSet = ls; + if (ls) + { + // only update lease set if found and newer than previous lease set + uint64_t oldExpire = 0; + if(m_RemoteLeaseSet) oldExpire = m_RemoteLeaseSet->GetExpirationTime(); + if(ls && ls->GetExpirationTime() > oldExpire) m_RemoteLeaseSet = ls; + } + FlushSendQueue (false); // process deferred flush } void DatagramSession::RequestUpdatedLeaseSet () @@ -765,10 +768,12 @@ namespace datagram } } - void DatagramSession::FlushSendQueue () + void DatagramSession::FlushSendQueue (bool waitForLeaseSet) { if (m_SendQueue.empty ()) return; auto routingPath = GetSharedRoutingPath(); + if (!routingPath && waitForLeaseSet && m_RequestingLS) + return; // defer to HandleLeaseSetUpdated // if we don't have a routing path we will drop all queued messages if(routingPath && routingPath->outboundTunnel && routingPath->remoteLease) { diff --git a/libi2pd/Datagram.h b/libi2pd/Datagram.h index 478ec51d..7b4b938c 100644 --- a/libi2pd/Datagram.h +++ b/libi2pd/Datagram.h @@ -73,7 +73,7 @@ namespace datagram /** send an i2np message to remote endpoint for this session */ void SendMsg(std::shared_ptr msg); - void FlushSendQueue(); + void FlushSendQueue(bool waitForLeaseSet = true); /** get the last time in milliseconds for when we used this datagram session */ uint64_t LastActivity() const { return m_LastUse; }