Skip to content

Commit

Permalink
Merge pull request #999 from loki-project/dev
Browse files Browse the repository at this point in the history
merge dev into master for 0.6.1
  • Loading branch information
majestrate authored Dec 22, 2019
2 parents 9444a7b + 7672294 commit 5cddf1d
Show file tree
Hide file tree
Showing 24 changed files with 306 additions and 579 deletions.
32 changes: 24 additions & 8 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,44 @@ stages:
# - "lokinet"

# we'll just try our travis set up for now
build:linux:
image: ubuntu:latest
build:linux_release:
image: ubuntu:xenial
tags:
- linux
stage: build
before_script:
- apt-get update && apt-get install -y build-essential cmake git libcap-dev bsdmainutils ninja-build curl git ca-certificates ccache libuv1-dev libsodium-dev
- apt-get update && apt-get install -y binutils-gold build-essential bsdmainutils ca-certificates ccache cmake curl git libcap-dev libcurl4-openssl-dev libsodium-dev libuv1-dev ninja-build
script:
- make STATIC_LINK=OFF
- DOWNLOAD_SODIUM=ON BUILD_TYPE=Release STATIC_LINK=OFF NINJA=ninja make
artifacts:
paths:
- "lokinet"
- "build/daemon/lokinet"
- "build/daemon/lokinetctl"

build:freebsd:
build:linux_debug:
image: ubuntu:xenial
tags:
- freebsd
- linux
stage: build
before_script:
- apt-get update && apt-get install -y binutils-gold build-essential bsdmainutils ca-certificates ccache cmake curl git libcap-dev libcurl4-openssl-dev libsodium-dev libuv1-dev ninja-build
script:
- gmake
- DOWNLOAD_SODIUM=ON BUILD_TYPE=Debug IS_NOTIFICATION=1 STATIC_LINK=OFF NINJA=ninja make
artifacts:
paths:
- "lokinet"
- "lokinetctl"

# needs libsodium (probably libuv and libcurl too)
#build:freebsd:
# tags:
# - freebsd
# stage: build
# script:
# - gmake
# artifacts:
# paths:
# - "lokinet"

#build:windows:
# tags:
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ script:
elif [[ ! -z $DOCKER_FILE ]]; then
travis_wait docker build -f $DOCKER_FILE .;
else
travis_wait make ${MAKE_TARGET:-test};
travis_wait make DOWNLOAD_SODIUM=ON ${MAKE_TARGET:-test};
fi

after_script:
Expand Down
9 changes: 0 additions & 9 deletions include/llarp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
#include <stdint.h>
#include <unistd.h>

#if defined(_WIN32)
#ifdef _MSC_VER
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#else
#define ssize_t long
#endif
#endif

#ifdef __cplusplus
extern "C"
{
Expand Down
1 change: 0 additions & 1 deletion llarp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ set(LIB_UTIL_SRC
util/thread/thread_pool.cpp
util/thread/threading.cpp
util/thread/threadpool.cpp
util/thread/timer.cpp
util/thread/timerqueue.cpp
util/time.cpp
util/types.cpp
Expand Down
4 changes: 2 additions & 2 deletions llarp/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,9 @@ llarp_generic_ensure_config(std::ofstream &f, std::string basepath,

f << "\n\n";

f << "# admin api (disabled by default)\n";
f << "# admin api\n";
f << "[api]\n";
f << "enabled=false\n";
f << "enabled=true\n";
f << "#authkey=insertpubkey1here\n";
f << "#authkey=insertpubkey2here\n";
f << "#authkey=insertpubkey3here\n";
Expand Down
1 change: 1 addition & 0 deletions llarp/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ __ ___ ____ _ _ ___ _ _ ____
llarp::LogInfo(llarp::VERSION_FULL, " ", llarp::RELEASE_MOTTO);
llarp::LogInfo("starting up");
mainloop = llarp_make_ev_loop();
logic->set_event_loop(mainloop.get());

mainloop->set_logic(logic);

Expand Down
48 changes: 23 additions & 25 deletions llarp/dht/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ namespace llarp
GetIntroSetByServiceAddress(
const llarp::service::Address& addr) const override;

static void
handle_cleaner_timer(void* user, uint64_t orig, uint64_t left);
void
handle_cleaner_timer(uint64_t interval);

static void
handle_explore_timer(void* user, uint64_t orig, uint64_t left);
void
handle_explore_timer(uint64_t interval);

/// explore dht for new routers
void
Expand Down Expand Up @@ -338,34 +338,28 @@ namespace llarp
}

void
Context::handle_explore_timer(void* u, uint64_t orig, uint64_t left)
Context::handle_explore_timer(uint64_t interval)
{
if(left)
return;
auto* ctx = static_cast< Context* >(u);
const auto num =
std::min(ctx->router->NumberOfConnectedRouters(), size_t(4));
const auto num = std::min(router->NumberOfConnectedRouters(), size_t(4));
if(num)
ctx->Explore(num);
ctx->router->logic()->call_later({orig, ctx, &handle_explore_timer});
Explore(num);
router->logic()->call_later(
interval,
std::bind(&llarp::dht::Context::handle_explore_timer, this,
interval));
}

void
Context::handle_cleaner_timer(void* u,
__attribute__((unused)) uint64_t orig,
uint64_t left)
Context::handle_cleaner_timer(__attribute__((unused)) uint64_t interval)
{
if(left)
return;
auto* ctx = static_cast< Context* >(u);
// clean up transactions
ctx->CleanupTX();
CleanupTX();

if(ctx->_services)
if(_services)
{
// expire intro sets
auto now = ctx->Now();
auto& nodes = ctx->_services->nodes;
auto now = Now();
auto& nodes = _services->nodes;
auto itr = nodes.begin();
while(itr != nodes.end())
{
Expand All @@ -378,7 +372,7 @@ namespace llarp
++itr;
}
}
ctx->ScheduleCleanupTimer();
ScheduleCleanupTimer();
}

std::set< service::IntroSet >
Expand Down Expand Up @@ -528,15 +522,19 @@ namespace llarp
// start exploring

r->logic()->call_later(
{exploreInterval, this, &llarp::dht::Context::handle_explore_timer});
exploreInterval,
std::bind(&llarp::dht::Context::handle_explore_timer, this,
exploreInterval));
// start cleanup timer
ScheduleCleanupTimer();
}

void
Context::ScheduleCleanupTimer()
{
router->logic()->call_later({1000, this, &handle_cleaner_timer});
router->logic()->call_later(
1000,
std::bind(&llarp::dht::Context::handle_cleaner_timer, this, 1000));
}

void
Expand Down
6 changes: 1 addition & 5 deletions llarp/ev/ev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev,
{
ev->update_time();
ev->tick(EV_TICK_INTERVAL);
if(ev->running())
{
ev->update_time();
logic->tick(ev->time_now());
}
llarp::LogContext::Instance().logStream->Tick(ev->time_now());
}
logic->clear_event_loop();
ev->stopped();
}

Expand Down
10 changes: 0 additions & 10 deletions llarp/ev/ev.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#include <wspiapi.h>

#if defined(_WIN32)
#ifdef _MSC_VER
#include <BaseTsd.h>
typedef SSIZE_T ssize_t;
#else
#define ssize_t long
#endif
#endif

#else
#include <netinet/in.h>
#include <sys/socket.h>
Expand Down
7 changes: 7 additions & 0 deletions llarp/ev/ev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,13 @@ struct llarp_ev_loop
virtual int
tick(int ms) = 0;

virtual uint32_t
call_after_delay(llarp_time_t delay_ms,
std::function< void(void) > callback) = 0;

virtual void
cancel_delayed_call(uint32_t call_id) = 0;

virtual bool
add_ticker(std::function< void(void) > ticker) = 0;

Expand Down
Loading

0 comments on commit 5cddf1d

Please sign in to comment.