start work on sighup

pull/598/head
Jeff Becker 5 years ago
parent a4ed8991b8
commit a53da68700
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -348,8 +348,15 @@ __ ___ ____ _ _ ___ _ _ ____
llarp::LogInfo("SIGHUP"); llarp::LogInfo("SIGHUP");
if(router) if(router)
{ {
router->hiddenServiceContext().ForEachService(
[](const std::string &name,
const llarp::service::Endpoint_ptr &ep) -> bool {
ep->ResetInternalState();
llarp::LogInfo("Reset internal state for ", name);
return true;
});
Config newconfig; Config newconfig;
if(newconfig.Load(configfile.c_str())) if(!newconfig.Load(configfile.c_str()))
{ {
llarp::LogError("failed to load config file ", configfile); llarp::LogError("failed to load config file ", configfile);
return; return;

@ -141,7 +141,7 @@ namespace llarp
uint8_t queue_idx = pktbuf.sz / llarp::routing::ExitPadSize; uint8_t queue_idx = pktbuf.sz / llarp::routing::ExitPadSize;
if(m_DownstreamQueues.find(queue_idx) == m_DownstreamQueues.end()) if(m_DownstreamQueues.find(queue_idx) == m_DownstreamQueues.end())
m_DownstreamQueues.emplace(queue_idx, InboundTrafficQueue_t{}); m_DownstreamQueues.emplace(queue_idx, InboundTrafficQueue_t{});
auto& queue = m_DownstreamQueues[queue_idx]; auto& queue = m_DownstreamQueues[queue_idx];
if(queue.size() == 0) if(queue.size() == 0)
{ {
queue.emplace_back(); queue.emplace_back();

@ -48,8 +48,7 @@ namespace llarp
return m_BundleRC; return m_BundleRC;
} }
bool bool UrgentBuild(llarp_time_t) const override;
UrgentBuild(llarp_time_t) const override;
void void
HandlePathDied(llarp::path::Path_ptr p) override; HandlePathDied(llarp::path::Path_ptr p) override;

@ -186,10 +186,11 @@ namespace llarp
} }
bool bool
ExitEndpoint::VisitEndpointsFor(const PubKey & pk, std::function<bool(exit::Endpoint * const)> visit) ExitEndpoint::VisitEndpointsFor(
const PubKey &pk, std::function< bool(exit::Endpoint *const) > visit)
{ {
auto range = m_ActiveExits.equal_range(pk); auto range = m_ActiveExits.equal_range(pk);
auto itr = range.first; auto itr = range.first;
while(itr != range.second) while(itr != range.second)
{ {
if(visit(itr->second.get())) if(visit(itr->second.get()))
@ -228,18 +229,17 @@ namespace llarp
return; return;
} }
} }
if(!VisitEndpointsFor(pk, [&](exit::Endpoint * const ep) -> bool if(!VisitEndpointsFor(pk, [&](exit::Endpoint *const ep) -> bool {
{ if(!ep->QueueInboundTraffic(ManagedBuffer{pkt.Buffer()}))
if(!ep->QueueInboundTraffic(ManagedBuffer{pkt.Buffer()})) {
{ LogWarn(Name(), " dropped inbound traffic for session ", pk,
LogWarn(Name(), " dropped inbound traffic for session ", pk, " as we are overloaded (probably)");
" as we are overloaded (probably)"); // continue iteration
// continue iteration return true;
return true; }
} // break iteration
// break iteration return false;
return false; }))
}))
{ {
// we may have all dead sessions, wtf now? // we may have all dead sessions, wtf now?
LogWarn(Name(), " dropped inbound traffic for session ", pk, LogWarn(Name(), " dropped inbound traffic for session ", pk,

@ -26,7 +26,8 @@ namespace llarp
Name() const; Name() const;
bool bool
VisitEndpointsFor(const PubKey & pk, std::function<bool(exit::Endpoint * const)> visit); VisitEndpointsFor(const PubKey& pk,
std::function< bool(exit::Endpoint* const) > visit);
util::StatusObject util::StatusObject
ExtractStatus() const; ExtractStatus() const;

@ -433,6 +433,14 @@ namespace llarp
return true; return true;
} }
void
TunEndpoint::ResetInternalState()
{
service::Endpoint::ResetInternalState();
if(m_Exit)
m_Exit->ResetInternalState();
}
// FIXME: pass in which question it should be addressing // FIXME: pass in which question it should be addressing
bool bool
TunEndpoint::ShouldHookDNSMessage(const dns::Message &msg) const TunEndpoint::ShouldHookDNSMessage(const dns::Message &msg) const

@ -153,6 +153,9 @@ namespace llarp
void void
Flush(); Flush();
void
ResetInternalState() override;
protected: protected:
using PacketQueue_t = llarp::util::CoDelQueue< using PacketQueue_t = llarp::util::CoDelQueue<
net::IPv4Packet, net::IPv4Packet::GetTime, net::IPv4Packet::PutTime, net::IPv4Packet, net::IPv4Packet::GetTime, net::IPv4Packet::PutTime,

@ -181,6 +181,12 @@ namespace llarp
{ {
} }
void
Builder::ResetInternalState()
{
buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
}
void void
Builder::Tick(llarp_time_t now) Builder::Tick(llarp_time_t now)
{ {

@ -52,6 +52,9 @@ namespace llarp
virtual bool virtual bool
ShouldBundleRC() const = 0; ShouldBundleRC() const = 0;
virtual void
ResetInternalState() override;
/// return true if we hit our soft limit for building paths too fast /// return true if we hit our soft limit for building paths too fast
bool bool
BuildCooldownHit(llarp_time_t now) const; BuildCooldownHit(llarp_time_t now) const;

@ -216,6 +216,10 @@ namespace llarp
return false; return false;
} }
/// reset all cooldown timers
virtual void
ResetInternalState() = 0;
virtual bool virtual bool
SelectHop(llarp_nodedb* db, const RouterContact& prev, RouterContact& cur, SelectHop(llarp_nodedb* db, const RouterContact& prev, RouterContact& cur,
size_t hop, PathRole roles) = 0; size_t hop, PathRole roles) = 0;

@ -596,6 +596,19 @@ namespace llarp
return false; return false;
} }
void
Endpoint::ResetInternalState()
{
path::Builder::ResetInternalState();
static auto resetState = [](auto& container) {
std::for_each(container.begin(), container.end(),
[](auto& item) { item.second->ResetInternalState(); });
};
resetState(m_RemoteSessions);
resetState(m_SNodeSessions);
}
bool bool
Endpoint::ShouldPublishDescriptors(llarp_time_t now) const Endpoint::ShouldPublishDescriptors(llarp_time_t now) const
{ {

@ -82,6 +82,9 @@ namespace llarp
return huint32_t{0}; return huint32_t{0};
} }
virtual void
ResetInternalState() override;
/// router's logic /// router's logic
/// use when sending any data on a path /// use when sending any data on a path
Logic* Logic*

Loading…
Cancel
Save