mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
49b9ad7197
* partial tun code refactor * take out the trash * move vpn platform code into llarp/vpn/platform.cpp * fix hive build * fix win32 * fix memory leak on win32 * reduce cpu use * make macos compile * win32 patches: * use wepoll for zmq * use all cores on windows iocp read loop * fix zmq patch for windows * clean up cmake for win32 * add uninstall before reinstall option to win32 installer * more ipv6 stuff * make it compile * fix up route poker * remove an unneeded code block in macos wtf * always use call to system * fix route poker behavior on macos * disable ipv6 on windows for now * cpu perf improvement: * colease calls to Router::PumpLL to 1 per event loop wakeup * set up THEN add addresses * emulate proactor event loop on win32 * remove excessively verbose error message * fix issue #1499 * exclude uv_poll from win32 so that it can start up * update logtag to include directory * create minidump on windows if there was a crash * make windows happy * use dmp suffix on minidump files * typo fix * address feedback from jason * use PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR * quote $@ in apply-patches in case path has spaces in it * address feedback from tom * remove llarp/ev/pipe * add comments for clairification * make event loop queue size constant named
74 lines
1.5 KiB
C++
74 lines
1.5 KiB
C++
#include <ev/ev.h>
|
|
#include <util/mem.hpp>
|
|
#include <util/str.hpp>
|
|
#include <util/thread/logic.hpp>
|
|
|
|
#include <cstddef>
|
|
#include <cstring>
|
|
#include <string_view>
|
|
|
|
// We libuv now
|
|
#include <ev/ev_libuv.hpp>
|
|
|
|
llarp_ev_loop_ptr
|
|
llarp_make_ev_loop(size_t queueLength)
|
|
{
|
|
llarp_ev_loop_ptr r = std::make_shared<libuv::Loop>(queueLength);
|
|
r->init();
|
|
r->update_time();
|
|
return r;
|
|
}
|
|
|
|
void
|
|
llarp_ev_loop_run_single_process(llarp_ev_loop_ptr ev, std::shared_ptr<llarp::Logic> logic)
|
|
{
|
|
if (ev == nullptr or logic == nullptr)
|
|
return;
|
|
ev->run();
|
|
logic->clear_event_loop();
|
|
ev->stopped();
|
|
}
|
|
|
|
int
|
|
llarp_ev_add_udp(const llarp_ev_loop_ptr& ev, struct llarp_udp_io* udp, const llarp::SockAddr& src)
|
|
{
|
|
if (ev == nullptr or udp == nullptr)
|
|
{
|
|
llarp::LogError("Attempting llarp_ev_add_udp() with null event loop or udp io struct.");
|
|
return -1;
|
|
}
|
|
udp->parent = ev.get();
|
|
if (ev->udp_listen(udp, src))
|
|
return 0;
|
|
llarp::LogError("llarp_ev_add_udp() call to udp_listen failed.");
|
|
return -1;
|
|
}
|
|
|
|
int
|
|
llarp_ev_close_udp(struct llarp_udp_io* udp)
|
|
{
|
|
if (udp->parent->udp_close(udp))
|
|
return 0;
|
|
return -1;
|
|
}
|
|
|
|
llarp_time_t
|
|
llarp_ev_loop_time_now_ms(const llarp_ev_loop_ptr& loop)
|
|
{
|
|
if (loop)
|
|
return loop->time_now();
|
|
return llarp::time_now_ms();
|
|
}
|
|
|
|
void
|
|
llarp_ev_loop_stop(const llarp_ev_loop_ptr& loop)
|
|
{
|
|
loop->stop();
|
|
}
|
|
|
|
int
|
|
llarp_ev_udp_sendto(struct llarp_udp_io* udp, const llarp::SockAddr& to, const llarp_buffer_t& buf)
|
|
{
|
|
return udp->sendto(udp, to, buf.base, buf.sz);
|
|
}
|