Introduce debug version EventCoreEpollDebug.

Outputs some debug log messages for the epoll backend.
This commit is contained in:
Sönke Ludwig 2016-11-29 11:56:23 +01:00
parent c85d546efd
commit ba61afbc2b

View file

@ -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;