lokinet/llarp/ev/vpnio.cpp
Stephen Shelton 273270916e
The Great Wall of Blame
This commit reflects changes to clang-format rules. Unfortunately,
these rule changes create a massive change to the codebase, which
causes an apparent rewrite of git history.

Git blame's --ignore-rev flag can be used to ignore this commit when
attempting to `git blame` some code.
2020-04-07 12:38:56 -06:00

31 lines
606 B
C++

#include <ev/vpnio.hpp>
#include <llarp.hpp>
#include <router/abstractrouter.hpp>
#include <util/thread/logic.hpp>
void
llarp_vpn_io_impl::AsyncClose()
{
reader.queue.disable();
writer.queue.disable();
CallSafe(std::bind(&llarp_vpn_io_impl::Expunge, this));
}
void
llarp_vpn_io_impl::CallSafe(std::function<void(void)> f)
{
auto ctx = llarp::Context::Get(ptr);
if (ctx && ctx->CallSafe(f))
return;
else if (ctx == nullptr || ctx->logic == nullptr)
f();
}
void
llarp_vpn_io_impl::Expunge()
{
parent->impl = nullptr;
if (parent->closed)
parent->closed(parent);
delete this;
}