From ba61afbc2b274d4377521324ef9feb23be24949f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 29 Nov 2016 11:56:23 +0100 Subject: [PATCH] Introduce debug version EventCoreEpollDebug. Outputs some debug log messages for the epoll backend. --- source/eventcore/drivers/epoll.d | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/eventcore/drivers/epoll.d b/source/eventcore/drivers/epoll.d index cbaf2d4..9432832 100644 --- a/source/eventcore/drivers/epoll.d +++ b/source/eventcore/drivers/epoll.d @@ -37,16 +37,16 @@ final class EpollEventLoop : PosixEventLoop { import std.algorithm : min; //assert(Fiber.getThis() is null, "processEvents may not be called from within a fiber!"); - //print("wait %s", m_events.length); + debug (EventCoreEpollDebug) print("Epoll wait %s, %s", m_events.length, timeout); long tomsec; if (timeout == Duration.max) tomsec = long.max; else tomsec = (timeout.total!"hnsecs" + 9999) / 10_000; auto ret = epoll_wait(m_epoll, m_events.ptr, cast(int)m_events.length, tomsec > int.max ? -1 : cast(int)tomsec); - //print("wait done %s", ret); + debug (EventCoreEpollDebug) print("Epoll wait done: %s", ret); if (ret > 0) { foreach (ref evt; m_events[0 .. ret]) { - //print("event %s %s", evt.data.fd, evt.events); + debug (EventCoreEpollDebug) print("Epoll event on %s: %s", evt.data.fd, evt.events); auto fd = cast(FD)evt.data.fd; if (evt.events & EPOLLIN) notify!(EventType.read)(fd); if (evt.events & EPOLLOUT) notify!(EventType.write)(fd); @@ -65,7 +65,7 @@ final class EpollEventLoop : PosixEventLoop { override void registerFD(FD fd, EventMask mask) { - //print("register %s %s", fd, mask); + debug (EventCoreEpollDebug) print("Epoll register FD %s: %s", fd, mask); epoll_event ev; ev.events |= EPOLLET; if (mask & EventMask.read) ev.events |= EPOLLIN; @@ -77,12 +77,13 @@ final class EpollEventLoop : PosixEventLoop { override void unregisterFD(FD fd) { + debug (EventCoreEpollDebug) print("Epoll unregister FD %s", fd); () @trusted { epoll_ctl(m_epoll, EPOLL_CTL_DEL, fd, null); } (); } override void updateFD(FD fd, EventMask mask) { - //print("update %s %s", fd, mask); + debug (EventCoreEpollDebug) print("Epoll update FD %s: %s", fd, mask); epoll_event ev; ev.events |= EPOLLET; //ev.events = EPOLLONESHOT;