fix BSD compile issue, added some debug, OSX compile fixes

pull/1/head
Ryan Tharp 6 years ago
parent 3f6a5c4ca5
commit 34dca85780

@ -5,18 +5,24 @@
#if __FreeBSD__ #if __FreeBSD__
// kqueue / kevent // kqueue / kevent
//# include <sys/types.h> // already in net.h
# include <sys/event.h> # include <sys/event.h>
# include <sys/time.h> # include <sys/time.h>
#endif #endif
#if (__APPLE__ && __MACH__)
// kqueue / kevent
# include <sys/event.h>
# include <sys/time.h>
#endif
//#include <sys/socket.h> // MacOS needs this
//#include <ifaddrs.h> #ifndef SOCK_NONBLOCK
# include <fcntl.h>
# define SOCK_NONBLOCK O_NONBLOCK
#endif
// original upstream // original upstream
#include <unistd.h> #include <unistd.h>
#include <cstdio> #include <cstdio>
#include "ev.hpp" #include "ev.hpp"
#include "logger.hpp" #include "logger.hpp"
@ -50,7 +56,9 @@ namespace llarp
virtual int virtual int
sendto(const sockaddr* to, const void* data, size_t sz) sendto(const sockaddr* to, const void* data, size_t sz)
{ {
printf("kqueue:::udp_listener::sendto size[%d]\n", sz);
socklen_t slen; socklen_t slen;
printf("kqueue:::udp_listener::sendto af[%d]\n", to->sa_family);
switch(to->sa_family) switch(to->sa_family)
{ {
case AF_INET: case AF_INET:
@ -62,9 +70,10 @@ namespace llarp
default: default:
return -1; return -1;
} }
printf("kqueue:::udp_listener::sendto slen[%d]\n", slen);
ssize_t sent = ::sendto(fd, data, sz, SOCK_NONBLOCK, to, slen); ssize_t sent = ::sendto(fd, data, sz, SOCK_NONBLOCK, to, slen);
if(sent == -1) if(sent == -1)
perror("sendto()"); perror("kqueue sendto()");
return sent; return sent;
} }
}; };
@ -164,7 +173,7 @@ struct llarp_kqueue_loop : public llarp_ev_loop
} }
} }
llarp::Addr a(*addr); llarp::Addr a(*addr);
llarp::Info(__FILE__, "bind to ", a.to_string()); llarp::Info(__FILE__, "bind to ", a);
if(bind(fd, addr, slen) == -1) if(bind(fd, addr, slen) == -1)
{ {
perror("bind()"); perror("bind()");

Loading…
Cancel
Save