Skip to content

Commit

Permalink
don't defer call to ready hook with timer call it right away because …
Browse files Browse the repository at this point in the history
…we are ready
  • Loading branch information
majestrate committed May 16, 2021
1 parent 432e7f2 commit f172db7
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions llarp/service/outbound_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,26 +348,14 @@ namespace llarp

if (ReadyToSend() and m_ReadyHook)
{
KeepAlive();
const auto path = GetPathByRouter(remoteIntro.router);
if (not path)
{
LogWarn(Name(), " ready but no path to ", remoteIntro.router, " ???");
return false;
return true;
}
const auto rtt = (path->intro.latency + remoteIntro.latency) * 2;
m_router->loop()->call_later(
rtt, [rtt, self = shared_from_this(), hook = std::move(m_ReadyHook)]() {
LogInfo(
self->Name(),
" is ready, RTT is measured as ",
self->estimatedRTT,
" approximated as ",
rtt,
" delta=",
rtt - self->estimatedRTT);
hook(self.get());
});
m_ReadyHook(this);
m_ReadyHook = nullptr;
}

if (lastGoodSend > 0s and now >= lastGoodSend + (sendTimeout / 2))
Expand Down

0 comments on commit f172db7

Please sign in to comment.