Minor fixes around Context

pull/1312/head
Stephen Shelton 4 years ago
parent 552dcce5fd
commit ed47ba998f
No known key found for this signature in database
GPG Key ID: EE4BADACCE8B631C

@ -98,7 +98,7 @@ run_main_context(const fs::path confFile, const llarp::RuntimeOptions opts)
llarp::Config conf;
conf.Load(confFile, opts.isRouter, confFile.parent_path());
ctx = std::shared_ptr<llarp::Context>();
ctx = std::make_shared<llarp::Context>();
ctx->Configure(opts, {});
signal(SIGINT, handle_signal);
@ -297,7 +297,23 @@ main(int argc, char* argv[])
} while (ftr.wait_for(std::chrono::seconds(1)) != std::future_status::ready);
main_thread.join();
const auto code = ftr.get();
int code = 0;
try
{
code = ftr.get();
}
catch (const std::exception& e)
{
std::cerr << "main thread threw exception: " << e.what() << std::endl;
code = 1;
}
catch (...)
{
std::cerr << "main thread threw non-standard exception" << std::endl;
code = 2;
}
llarp::LogContext::Instance().ImmediateFlush();
#ifdef _WIN32

@ -6,6 +6,7 @@
#include <ev/ev.hpp>
#include <nodedb.hpp>
#include <crypto/crypto.hpp>
#include <router/abstractrouter.hpp>
#include <iostream>
#include <map>
@ -18,7 +19,6 @@ struct llarp_ev_loop;
namespace llarp
{
class Logic;
struct AbstractRouter;
struct Config;
struct RouterContact;
namespace thread
@ -35,12 +35,12 @@ namespace llarp
struct Context
{
std::unique_ptr<Crypto> crypto;
std::unique_ptr<CryptoManager> cryptoManager;
std::unique_ptr<AbstractRouter> router;
std::shared_ptr<Logic> logic;
std::unique_ptr<Config> config;
std::unique_ptr<llarp_nodedb> nodedb;
std::unique_ptr<Crypto> crypto = nullptr;
std::unique_ptr<CryptoManager> cryptoManager = nullptr;
std::unique_ptr<AbstractRouter> router = nullptr;
std::shared_ptr<Logic> logic = nullptr;
std::unique_ptr<Config> config = nullptr;
std::unique_ptr<llarp_nodedb> nodedb = nullptr;
llarp_ev_loop_ptr mainloop;
std::string nodedb_dir;

@ -30,7 +30,7 @@ namespace llarp
bool
Context::Configure(const RuntimeOptions& opts, std::optional<fs::path> dataDir)
{
if (not config)
if (nullptr == config.get())
config = std::make_unique<Config>();
fs::path defaultDataDir = dataDir ? *dataDir : GetDefaultDataDir();

Loading…
Cancel
Save