mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
limit calls
This commit is contained in:
parent
5d8f547d33
commit
5924a2cec0
|
@ -35,8 +35,13 @@ namespace llarp
|
|||
void
|
||||
TunEndpoint::tunifTick(llarp_tun_io *tun)
|
||||
{
|
||||
auto *self = static_cast< TunEndpoint * >(tun->user);
|
||||
LogicCall(self->m_router->logic(), [self]() { self->Flush(); });
|
||||
auto *self = static_cast< TunEndpoint * >(tun->user);
|
||||
const auto now = self->Now();
|
||||
if(self->ShouldFlushNow(now))
|
||||
{
|
||||
self->m_LastFlushAt = now;
|
||||
LogicCall(self->m_router->logic(), [self]() { self->Flush(); });
|
||||
}
|
||||
}
|
||||
|
||||
TunEndpoint::TunEndpoint(const std::string &nickname, AbstractRouter *r,
|
||||
|
|
|
@ -184,7 +184,15 @@ namespace llarp
|
|||
ResetInternalState() override;
|
||||
|
||||
protected:
|
||||
using PacketQueue_t = llarp::util::CoDelQueue<
|
||||
bool
|
||||
ShouldFlushNow(llarp_time_t now) const
|
||||
{
|
||||
static constexpr llarp_time_t FlushInterval = 50;
|
||||
return now >= m_LastFlushAt + FlushInterval;
|
||||
}
|
||||
|
||||
llarp_time_t m_LastFlushAt = 0;
|
||||
using PacketQueue_t = llarp::util::CoDelQueue<
|
||||
net::IPPacket, net::IPPacket::GetTime, net::IPPacket::PutTime,
|
||||
net::IPPacket::CompareOrder, net::IPPacket::GetNow >;
|
||||
|
||||
|
|
Loading…
Reference in a new issue