diff options
Diffstat (limited to 'src/event/SocketMonitor.cxx')
-rw-r--r-- | src/event/SocketMonitor.cxx | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx index 2b97059f7..769efba82 100644 --- a/src/event/SocketMonitor.cxx +++ b/src/event/SocketMonitor.cxx @@ -28,11 +28,10 @@ #ifdef WIN32 #include <winsock2.h> #else -#include <sys/types.h> #include <sys/socket.h> #endif -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP void SocketMonitor::Dispatch(unsigned flags) @@ -43,7 +42,9 @@ SocketMonitor::Dispatch(unsigned flags) Cancel(); } -#else +#endif + +#ifdef USE_GLIB_EVENTLOOP /* * GSource methods @@ -113,14 +114,14 @@ void SocketMonitor::Open(int _fd) { assert(fd < 0); -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP assert(source == nullptr); #endif assert(_fd >= 0); fd = _fd; -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP poll = {fd, 0, 0}; source = (Source *)g_source_new(&socket_monitor_source_funcs, @@ -142,7 +143,7 @@ SocketMonitor::Steal() int result = fd; fd = -1; -#ifndef USE_EPOLL +#ifdef USE_GLIB_EVENTLOOP g_source_destroy(&source->base); g_source_unref(&source->base); source = nullptr; @@ -156,9 +157,10 @@ SocketMonitor::Abandon() { assert(IsDefined()); -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP + int old_fd = fd; fd = -1; - loop.Abandon(*this); + loop.Abandon(old_fd, *this); #else Steal(); #endif @@ -178,7 +180,7 @@ SocketMonitor::Schedule(unsigned flags) if (flags == GetScheduledFlags()) return; -#ifdef USE_EPOLL +#ifdef USE_INTERNAL_EVENTLOOP if (scheduled_flags == 0) loop.AddFD(fd, flags, *this); else if (flags == 0) @@ -187,7 +189,9 @@ SocketMonitor::Schedule(unsigned flags) loop.ModifyFD(fd, flags, *this); scheduled_flags = flags; -#else +#endif + +#ifdef USE_GLIB_EVENTLOOP poll.events = flags; poll.revents &= flags; |