mirror of https://github.com/oxen-io/lokinet
add deadlock checker and revert bencode change from long ago
This commit is contained in:
parent
c5f198cfa1
commit
f56e543d75
|
@ -1,6 +1,6 @@
|
|||
#include <config/config.hpp> // for ensure_config
|
||||
#include <constants/version.hpp>
|
||||
#include <llarp.h>
|
||||
#include <llarp.hpp>
|
||||
#include <util/lokinet_init.h>
|
||||
#include <util/fs.hpp>
|
||||
#include <util/logging/logger.hpp>
|
||||
|
@ -270,6 +270,40 @@ main(int argc, char *argv[])
|
|||
do
|
||||
{
|
||||
// do periodic non lokinet related tasks here
|
||||
if(ctx != nullptr)
|
||||
{
|
||||
auto ctx_pp = llarp::Context::Get(ctx);
|
||||
if(ctx_pp != nullptr)
|
||||
{
|
||||
if(true) // ctx_pp->IsUp() and not ctx_pp->LooksAlive())
|
||||
{
|
||||
for(const auto &wtf : {"you have been visited by the mascott of the "
|
||||
"deadlocked router.",
|
||||
"⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⣀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⠄⠄⠄⠄",
|
||||
"⠄⠄⠄⠄⠄⢀⣀⣀⡀⠄⠄⠄⡠⢲⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠄⠄",
|
||||
"⠄⠄⠄⠔⣈⣀⠄⢔⡒⠳⡴⠊⠄⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣧⠄⠄",
|
||||
"⠄⢜⡴⢑⠖⠊⢐⣤⠞⣩⡇⠄⠄⠄⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠄⠝⠛⠋⠐",
|
||||
"⢸⠏⣷⠈⠄⣱⠃⠄⢠⠃⠐⡀⠄⠄⠄⠄⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠸⠄⠄⠄⠄",
|
||||
"⠈⣅⠞⢁⣿⢸⠘⡄⡆⠄⠄⠈⠢⡀⠄⠄⠄⠄⠄⠄⠉⠙⠛⠛⠛⠉⠉⡀⠄⠡⢀⠄⣀",
|
||||
"⠄⠙⡎⣹⢸⠄⠆⢘⠁⠄⠄⠄⢸⠈⠢⢄⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠃⠄⠄⠄⠄⠄",
|
||||
"⠄⠄⠑⢿⠈⢆⠘⢼⠄⠄⠄⠄⠸⢐⢾⠄⡘⡏⠲⠆⠠⣤⢤⢤⡤⠄⣖⡇⠄⠄⠄⠄⠄",
|
||||
"⣴⣶⣿⣿⣣⣈⣢⣸⠄⠄⠄⠄⡾⣷⣾⣮⣤⡏⠁⠘⠊⢠⣷⣾⡛⡟⠈⠄⠄⠄⠄⠄⠄",
|
||||
"⣿⣿⣿⣿⣿⠉⠒⢽⠄⠄⠄⠄⡇⣿⣟⣿⡇⠄⠄⠄⠄⢸⣻⡿⡇⡇⠄⠄⠄⠄⠄⠄⠄",
|
||||
"⠻⣿⣿⣿⣿⣄⠰⢼⠄⠄⠄⡄⠁⢻⣍⣯⠃⠄⠄⠄⠄⠈⢿⣻⠃⠈⡆⡄⠄⠄⠄⠄⠄",
|
||||
"⠄⠙⠿⠿⠛⣿⣶⣤⡇⠄⠄⢣⠄⠄⠈⠄⢠⠂⠄⠁⠄⡀⠄⠄⣀⠔⢁⠃⠄⠄⠄⠄⠄",
|
||||
"⠄⠄⠄⠄⠄⣿⣿⣿⣿⣾⠢⣖⣶⣦⣤⣤⣬⣤⣤⣤⣴⣶⣶⡏⠠⢃⠌⠄⠄⠄⠄⠄⠄",
|
||||
"⠄⠄⠄⠄⠄⠿⠿⠟⠛⡹⠉⠛⠛⠿⠿⣿⣿⣿⣿⣿⡿⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄",
|
||||
"⠠⠤⠤⠄⠄⣀⠄⠄⠄⠑⠠⣤⣀⣀⣀⡘⣿⠿⠙⠻⡍⢀⡈⠂⠄⠄⠄⠄⠄⠄⠄⠄⠄",
|
||||
"⠄⠄⠄⠄⠄⠄⠑⠠⣠⣴⣾⣿⣿⣿⣿⣿⣿⣇⠉⠄⠻⣿⣷⣄⡀⠄⠄⠄⠄⠄⠄⠄⠄",
|
||||
"file a bug report now or be cursed with this "
|
||||
"annoying image in your syslog for all time."})
|
||||
{
|
||||
LogError(wtf);
|
||||
}
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(ftr.wait_for(std::chrono::seconds(1)) != std::future_status::ready);
|
||||
|
||||
main_thread.join();
|
||||
|
|
|
@ -87,6 +87,12 @@ namespace llarp
|
|||
bool
|
||||
Configure();
|
||||
|
||||
bool
|
||||
IsUp() const;
|
||||
|
||||
bool
|
||||
LooksAlive() const;
|
||||
|
||||
/// close async
|
||||
void
|
||||
CloseAsync();
|
||||
|
@ -117,9 +123,6 @@ namespace llarp
|
|||
bool
|
||||
ReloadConfig();
|
||||
|
||||
void
|
||||
progress();
|
||||
|
||||
void
|
||||
setupMetrics(const MetricsConfig &metricsConfig);
|
||||
|
||||
|
|
|
@ -42,12 +42,6 @@ namespace llarp
|
|||
return logic && LogicCall(logic, f);
|
||||
}
|
||||
|
||||
void
|
||||
Context::progress()
|
||||
{
|
||||
std::cout << "." << std::flush;
|
||||
}
|
||||
|
||||
bool
|
||||
Context::Configure()
|
||||
{
|
||||
|
@ -169,6 +163,18 @@ __ ___ ____ _ _ ___ _ _ ____
|
|||
pidfile = fname;
|
||||
}
|
||||
|
||||
bool
|
||||
Context::IsUp() const
|
||||
{
|
||||
return router && router->IsRunning();
|
||||
}
|
||||
|
||||
bool
|
||||
Context::LooksAlive() const
|
||||
{
|
||||
return router && router->LooksAlive();
|
||||
}
|
||||
|
||||
int
|
||||
Context::LoadDatabase()
|
||||
{
|
||||
|
|
|
@ -140,6 +140,9 @@ namespace llarp
|
|||
virtual bool
|
||||
IsRunning() const = 0;
|
||||
|
||||
virtual bool
|
||||
LooksAlive() const = 0;
|
||||
|
||||
/// stop running the router logic gracefully
|
||||
virtual void
|
||||
Stop() = 0;
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace llarp
|
|||
|
||||
_stopping.store(false);
|
||||
_running.store(false);
|
||||
_lastTick = llarp::time_now_ms();
|
||||
}
|
||||
|
||||
Router::~Router()
|
||||
|
@ -750,7 +751,9 @@ namespace llarp
|
|||
});
|
||||
// expire paths
|
||||
paths.ExpirePaths(now);
|
||||
} // namespace llarp
|
||||
// update tick timestamp
|
||||
_lastTick = llarp::time_now_ms();
|
||||
}
|
||||
|
||||
bool
|
||||
Router::Sign(Signature &sig, const llarp_buffer_t &buf) const
|
||||
|
|
|
@ -222,6 +222,15 @@ namespace llarp
|
|||
return _hiddenServiceContext;
|
||||
}
|
||||
|
||||
llarp_time_t _lastTick = 0;
|
||||
|
||||
bool
|
||||
LooksAlive() const override
|
||||
{
|
||||
const llarp_time_t now = Now();
|
||||
return now <= _lastTick || (now - _lastTick) <= llarp_time_t{30000};
|
||||
}
|
||||
|
||||
using NetConfig_t = std::unordered_multimap< std::string, std::string >;
|
||||
|
||||
/// default network config for default network interface
|
||||
|
|
|
@ -78,14 +78,7 @@ bencode_write_bytestring(llarp_buffer_t* buff, const void* data, size_t sz)
|
|||
bool
|
||||
bencode_write_uint64(llarp_buffer_t* buff, uint64_t i)
|
||||
{
|
||||
// NetBSDs also do this shit in long mode, wouldn't be surprised
|
||||
// if all the BSDs do by default
|
||||
#if !defined(__LP64__) || (__APPLE__ && __MACH__) || (__NetBSD__) \
|
||||
|| (__OpenBSD__)
|
||||
if(!buff->writef("i%llu", i))
|
||||
#else
|
||||
if(!buff->writef("i%lu", i))
|
||||
#endif
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue