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");
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;
if(newconfig.Load(configfile.c_str()))
if(!newconfig.Load(configfile.c_str()))
{
llarp::LogError("failed to load config file ", configfile);
return;

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

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

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

@ -26,7 +26,8 @@ namespace llarp
Name() const;
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
ExtractStatus() const;

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

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

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

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

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

@ -596,6 +596,19 @@ namespace llarp
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
Endpoint::ShouldPublishDescriptors(llarp_time_t now) const
{

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

Loading…
Cancel
Save