mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
move packet flushing about
This commit is contained in:
parent
7ca82918b4
commit
98981c82cd
|
@ -22,6 +22,13 @@ namespace llarp
|
|||
return static_cast< TunEndpoint * >(tun->user)->Promise.get();
|
||||
}
|
||||
|
||||
static void
|
||||
tunifTick(llarp_tun_io *tun)
|
||||
{
|
||||
TunEndpoint *self = static_cast< TunEndpoint * >(tun->user);
|
||||
self->Flush();
|
||||
}
|
||||
|
||||
TunEndpoint::TunEndpoint(const std::string &nickname, llarp::Router *r)
|
||||
: service::Endpoint(nickname, r)
|
||||
, m_UserToNetworkPktQueue(nickname + "_sendq", r->netloop, r->netloop)
|
||||
|
@ -43,7 +50,7 @@ namespace llarp
|
|||
strncpy(tunif.ifaddr, DefaultTunSrcAddr, sizeof(tunif.ifaddr) - 1);
|
||||
strncpy(tunif.ifname, DefaultTunIfname, sizeof(tunif.ifname) - 1);
|
||||
#endif
|
||||
tunif.tick = &tunifBeforeWrite;
|
||||
tunif.tick = &tunifTick;
|
||||
tunif.before_write = &tunifBeforeWrite;
|
||||
tunif.recvpkt = &tunifRecvPkt;
|
||||
}
|
||||
|
@ -177,6 +184,12 @@ namespace llarp
|
|||
std::move(pkt));
|
||||
}
|
||||
|
||||
void
|
||||
TunEndpoint::Flush()
|
||||
{
|
||||
FlushSend();
|
||||
}
|
||||
|
||||
bool
|
||||
TunEndpoint::HandleHookedDNSMessage(
|
||||
dns::Message msg, std::function< void(dns::Message) > reply)
|
||||
|
@ -617,13 +630,6 @@ namespace llarp
|
|||
m_IPActivity[ip] = std::numeric_limits< uint64_t >::max();
|
||||
}
|
||||
|
||||
void
|
||||
TunEndpoint::handleTickTun(void *u)
|
||||
{
|
||||
TunEndpoint *self = static_cast< TunEndpoint * >(u);
|
||||
self->TickTun(self->Now());
|
||||
}
|
||||
|
||||
void
|
||||
TunEndpoint::TickTun(__attribute__((unused)) llarp_time_t now)
|
||||
{
|
||||
|
@ -639,8 +645,6 @@ namespace llarp
|
|||
if(!llarp_ev_tun_async_write(tun, pkt.Buffer()))
|
||||
llarp::LogWarn("packet dropped");
|
||||
});
|
||||
if(self->m_UserToNetworkPktQueue.Size())
|
||||
self->FlushSend();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -121,6 +121,10 @@ namespace llarp
|
|||
huint32_t
|
||||
ObtainIPForAddr(const byte_t* addr, bool serviceNode) override;
|
||||
|
||||
/// flush network traffic
|
||||
void
|
||||
Flush();
|
||||
|
||||
protected:
|
||||
using PacketQueue_t = llarp::util::CoDelQueue<
|
||||
net::IPv4Packet, net::IPv4Packet::GetTime, net::IPv4Packet::PutTime,
|
||||
|
|
Loading…
Reference in a new issue