Merge pull request #497 from michael-loki/kqueue_macos_fix

Fixup build on macOS
pull/504/head
Jeff 5 years ago committed by GitHub
commit b8a0912611
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -306,7 +306,7 @@ llarp_kqueue_loop::bind_tcp(llarp_tcp_acceptor* tcp, const sockaddr* bindaddr)
llarp::ev_io*
llarp_kqueue_loop::create_tun(llarp_tun_io* tun)
{
llarp::tun* t = new llarp::tun(tun, this);
llarp::tun* t = new llarp::tun(tun, shared_from_this());
if(t->setup())
return t;
delete t;
@ -381,8 +381,8 @@ llarp_kqueue_loop::tick(int ms)
if(events[idx].filter & EVFILT_READ)
{
IO([&]() -> ssize_t {
return ev->read(readbuf,
std::min(sizeof(readbuf), size_t(events[idx].data)));
return ev->read(
readbuf, std::min(sizeof(readbuf), size_t(events[idx].data)));
});
}
}

@ -42,7 +42,7 @@ namespace llarp
{
llarp_tun_io* t;
device* tunif;
tun(llarp_tun_io* tio, llarp_ev_loop* l)
tun(llarp_tun_io* tio, llarp_ev_loop_ptr l)
: ev_io(-1, new LossyWriteQueue_t("kqueue_tun_write", l, l))
, t(tio)
, tunif(tuntap_init()){};
@ -77,7 +77,9 @@ namespace llarp
} // namespace llarp
struct llarp_kqueue_loop final : public llarp_ev_loop
struct llarp_kqueue_loop final
: public llarp_ev_loop,
public std::enable_shared_from_this< llarp_kqueue_loop >
{
int kqueuefd;

@ -12,8 +12,18 @@ bool
llarp_ev_pkt_pipe::Start()
{
int _fds[2];
#if defined(__APPLE__)
if(pipe(_fds) == -1
&& fcntl(_fds[0], F_SETFL, fcntl(_fds[0], F_GETFL) | O_NONBLOCK))
{
return false;
}
#else
if(pipe2(_fds, O_DIRECT | O_NONBLOCK) == -1)
{
return false;
}
#endif
fd = _fds[0];
writefd = _fds[1];
return true;

Loading…
Cancel
Save