mirror of https://github.com/oxen-io/lokinet
Merge pull request #1844 from majestrate/sigusr1-wire-up-thaw-2022-01-27
wire up sigusr1 to trigger a network thaw on non win32 platforms
This commit is contained in:
commit
36925d0576
|
@ -0,0 +1,10 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
namespace llarp
|
||||||
|
{
|
||||||
|
using namespace std::literals;
|
||||||
|
/// how big of a time skip before we reset network state
|
||||||
|
constexpr auto TimeskipDetectedDuration = 1min;
|
||||||
|
} // namespace llarp
|
|
@ -166,6 +166,14 @@ namespace llarp
|
||||||
SigINT();
|
SigINT();
|
||||||
}
|
}
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
if (sig == SIGUSR1)
|
||||||
|
{
|
||||||
|
if (router and not router->IsServiceNode())
|
||||||
|
{
|
||||||
|
LogInfo("SIGUSR1: resetting network state");
|
||||||
|
router->Thaw();
|
||||||
|
}
|
||||||
|
}
|
||||||
if (sig == SIGHUP)
|
if (sig == SIGHUP)
|
||||||
{
|
{
|
||||||
Reload();
|
Reload();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <llarp/config/config.hpp>
|
#include <llarp/config/config.hpp>
|
||||||
#include <llarp/constants/proto.hpp>
|
#include <llarp/constants/proto.hpp>
|
||||||
#include <llarp/constants/files.hpp>
|
#include <llarp/constants/files.hpp>
|
||||||
|
#include <llarp/constants/time.hpp>
|
||||||
#include <llarp/crypto/crypto_libsodium.hpp>
|
#include <llarp/crypto/crypto_libsodium.hpp>
|
||||||
#include <llarp/crypto/crypto.hpp>
|
#include <llarp/crypto/crypto.hpp>
|
||||||
#include <llarp/dht/context.hpp>
|
#include <llarp/dht/context.hpp>
|
||||||
|
@ -807,6 +808,12 @@ namespace llarp
|
||||||
return;
|
return;
|
||||||
// LogDebug("tick router");
|
// LogDebug("tick router");
|
||||||
const auto now = Now();
|
const auto now = Now();
|
||||||
|
if (const auto delta = now - _lastTick; _lastTick != 0s and delta > TimeskipDetectedDuration)
|
||||||
|
{
|
||||||
|
// we detected a time skip into the futre, thaw the network
|
||||||
|
LogWarn("Timeskip of ", delta, " detected. Resetting network state");
|
||||||
|
Thaw();
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(WITH_SYSTEMD)
|
#if defined(WITH_SYSTEMD)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue