X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocketengines%2Fsocketengine_poll.cpp;h=339045a8c301c5ca75196cb06c90b4d4eb027278;hb=63e300ed082b82530ad5ae0949f45686746b7c9b;hp=4e6d0b9f5bf82b561f04eb36d227b919f7f4479a;hpb=5a6fd54f8fd217232f98804431928609580742bc;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 4e6d0b9f5..339045a8c 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -21,12 +21,7 @@ */ -#include -#include -#include -#include "exitcodes.h" #include "inspircd.h" -#include "socketengine.h" #include #include @@ -40,21 +35,12 @@ namespace std::vector events(16); /** This vector maps fds to an index in the events array. */ - std::vector fd_mappings(16); + std::vector fd_mappings(16, -1); } void SocketEngine::Init() { - struct rlimit limits; - if (!getrlimit(RLIMIT_NOFILE, &limits)) - { - MAX_DESCRIPTORS = limits.rlim_cur; - } - else - { - // MAX_DESCRIPTORS is mainly used for display purposes, it's not a problem that getrlimit() failed - MAX_DESCRIPTORS = -1; - } + LookupMaxFds(); } void SocketEngine::Deinit() @@ -172,7 +158,7 @@ int SocketEngine::DispatchEvents() int processed = 0; ServerInstance->UpdateTime(); - for (int index = 0; index < CurrentSetSize && processed < i; index++) + for (size_t index = 0; index < CurrentSetSize && processed < i; index++) { struct pollfd& pfd = events[index]; @@ -189,7 +175,7 @@ int SocketEngine::DispatchEvents() if (revents & POLLHUP) { - eh->HandleEvent(EVENT_ERROR, 0); + eh->OnEventHandlerError(0); continue; } @@ -200,14 +186,14 @@ int SocketEngine::DispatchEvents() int errcode; if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &errcode, &codesize) < 0) errcode = errno; - eh->HandleEvent(EVENT_ERROR, errcode); + eh->OnEventHandlerError(errcode); continue; } if (revents & POLLIN) { eh->SetEventMask(eh->GetEventMask() & ~FD_READ_WILL_BLOCK); - eh->HandleEvent(EVENT_READ); + eh->OnEventHandlerRead(); if (eh != GetRef(fd)) // whoops, deleted out from under us continue; @@ -221,7 +207,7 @@ int SocketEngine::DispatchEvents() // The vector could've been resized, reference can be invalid by now; don't use it events[index].events = mask_to_poll(mask); - eh->HandleEvent(EVENT_WRITE); + eh->OnEventHandlerWrite(); } }