move packet flushing about

pull/174/head
Jeff Becker 6 years ago
parent 7ca82918b4
commit 98981c82cd
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -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…
Cancel
Save