Introduce debug version EventCoreEpollDebug.
Outputs some debug log messages for the epoll backend.
This commit is contained in:
parent
c85d546efd
commit
ba61afbc2b
|
@ -37,16 +37,16 @@ final class EpollEventLoop : PosixEventLoop {
|
||||||
import std.algorithm : min;
|
import std.algorithm : min;
|
||||||
//assert(Fiber.getThis() is null, "processEvents may not be called from within a fiber!");
|
//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;
|
long tomsec;
|
||||||
if (timeout == Duration.max) tomsec = long.max;
|
if (timeout == Duration.max) tomsec = long.max;
|
||||||
else tomsec = (timeout.total!"hnsecs" + 9999) / 10_000;
|
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);
|
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) {
|
if (ret > 0) {
|
||||||
foreach (ref evt; m_events[0 .. ret]) {
|
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;
|
auto fd = cast(FD)evt.data.fd;
|
||||||
if (evt.events & EPOLLIN) notify!(EventType.read)(fd);
|
if (evt.events & EPOLLIN) notify!(EventType.read)(fd);
|
||||||
if (evt.events & EPOLLOUT) notify!(EventType.write)(fd);
|
if (evt.events & EPOLLOUT) notify!(EventType.write)(fd);
|
||||||
|
@ -65,7 +65,7 @@ final class EpollEventLoop : PosixEventLoop {
|
||||||
|
|
||||||
override void registerFD(FD fd, EventMask mask)
|
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;
|
epoll_event ev;
|
||||||
ev.events |= EPOLLET;
|
ev.events |= EPOLLET;
|
||||||
if (mask & EventMask.read) ev.events |= EPOLLIN;
|
if (mask & EventMask.read) ev.events |= EPOLLIN;
|
||||||
|
@ -77,12 +77,13 @@ final class EpollEventLoop : PosixEventLoop {
|
||||||
|
|
||||||
override void unregisterFD(FD fd)
|
override void unregisterFD(FD fd)
|
||||||
{
|
{
|
||||||
|
debug (EventCoreEpollDebug) print("Epoll unregister FD %s", fd);
|
||||||
() @trusted { epoll_ctl(m_epoll, EPOLL_CTL_DEL, fd, null); } ();
|
() @trusted { epoll_ctl(m_epoll, EPOLL_CTL_DEL, fd, null); } ();
|
||||||
}
|
}
|
||||||
|
|
||||||
override void updateFD(FD fd, EventMask mask)
|
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;
|
epoll_event ev;
|
||||||
ev.events |= EPOLLET;
|
ev.events |= EPOLLET;
|
||||||
//ev.events = EPOLLONESHOT;
|
//ev.events = EPOLLONESHOT;
|
||||||
|
|
Loading…
Reference in a new issue