mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
ping less and try not to double free in llarp_router::SendToOrQueue
This commit is contained in:
parent
ed5867e49f
commit
2b8bd11f5e
2 changed files with 21 additions and 10 deletions
|
@ -576,7 +576,9 @@ namespace llarp
|
|||
SendQueueBacklog = [&]() -> size_t { return sendq.size(); };
|
||||
|
||||
SendKeepAlive = [&]() -> bool {
|
||||
if(sendq.size() == 0 && state == eSessionReady)
|
||||
auto now = llarp_time_now_ms();
|
||||
if(sendq.size() == 0 && state == eSessionReady && now > lastActive
|
||||
&& now - lastActive > (sessionTimeout / 4))
|
||||
{
|
||||
DiscardMessage msg;
|
||||
byte_t tmp[128] = {0};
|
||||
|
|
|
@ -158,18 +158,27 @@ bool
|
|||
llarp_router::SendToOrQueue(const llarp::RouterID &remote,
|
||||
const llarp::ILinkMessage *msg)
|
||||
{
|
||||
llarp::ILinkLayer *chosen = nullptr;
|
||||
|
||||
if(inboundLinks.size() == 0)
|
||||
chosen = outboundLink.get();
|
||||
else
|
||||
chosen = inboundLinks[0].get();
|
||||
|
||||
if(chosen->HasSessionTo(remote))
|
||||
{
|
||||
SendTo(remote, msg, chosen);
|
||||
return true;
|
||||
if(outboundLink->HasSessionTo(remote))
|
||||
{
|
||||
SendTo(remote, msg, outboundLink.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(const auto &link : inboundLinks)
|
||||
{
|
||||
if(link->HasSessionTo(remote))
|
||||
{
|
||||
SendTo(remote, msg, link.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// no link available
|
||||
|
||||
// this will create an entry in the obmq if it's not already there
|
||||
auto itr = outboundMessageQueue.find(remote);
|
||||
if(itr == outboundMessageQueue.end())
|
||||
|
|
Loading…
Reference in a new issue