From 927123188c04980cb038d74e839593669dc77928 Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 22 May 2024 12:30:01 -0400 Subject: [PATCH] handle onDrop for request message in nedb requests thread --- libi2pd/NetDbRequests.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libi2pd/NetDbRequests.cpp b/libi2pd/NetDbRequests.cpp index 0ce6508d..fae838c3 100644 --- a/libi2pd/NetDbRequests.cpp +++ b/libi2pd/NetDbRequests.cpp @@ -266,13 +266,23 @@ namespace data if (direct && !nextFloodfill->IsReachableFrom (i2p::context.GetRouterInfo ()) && !i2p::transport::transports.IsConnected (nextFloodfill->GetIdentHash ())) direct = false; // floodfill can't be reached directly + auto s = shared_from_this (); + auto onDrop = [s, dest]() + { + if (dest->IsActive ()) + { + s->GetIOService ().post ([s, dest]() + { + if (dest->IsActive ()) s->SendNextRequest (dest); + }); + } + }; if (direct) { if (CheckLogLevel (eLogDebug)) LogPrint (eLogDebug, "NetDbReq: Try ", dest->GetDestination ().ToBase64 (), " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 (), " directly"); auto msg = dest->CreateRequestMessage (nextFloodfill->GetIdentHash ()); - auto s = shared_from_this (); - msg->onDrop = [s, dest]() { if (dest->IsActive ()) s->SendNextRequest (dest); }; + msg->onDrop = onDrop; i2p::transport::transports.SendMessage (nextFloodfill->GetIdentHash (), msg); } else @@ -287,8 +297,7 @@ namespace data if (CheckLogLevel (eLogDebug)) LogPrint (eLogDebug, "NetDbReq: Try ", dest->GetDestination ().ToBase64 (), " at ", count, " floodfill ", nextFloodfill->GetIdentHash ().ToBase64 (), " through tunnels"); auto msg = dest->CreateRequestMessage (nextFloodfill, inbound); - auto s = shared_from_this (); - msg->onDrop = [s, dest]() { if (dest->IsActive ()) s->SendNextRequest (dest); }; + msg->onDrop = onDrop; outbound->SendTunnelDataMsgTo (nextFloodfill->GetIdentHash (), 0, i2p::garlic::WrapECIESX25519MessageForRouter (msg, nextFloodfill->GetIdentity ()->GetEncryptionPublicKey ())); }