]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_poll.cpp
Merge the latest changes from insp20 into master.
[user/henk/code/inspircd.git] / src / socketengines / socketengine_poll.cpp
index 4eca494cfc01917f69bdf2c7479e24a37240811b..59991d80dbf224b8fd6ed24fb08c6f199ca8acf2 100644 (file)
  */
 
 
-#include <iostream>
-#include <vector>
-#include <string>
-#include <map>
 #include "exitcodes.h"
 #include "inspircd.h"
-#include "socketengine.h"
 
 #include <sys/poll.h>
 #include <sys/resource.h>
@@ -53,9 +48,8 @@ void SocketEngine::Init()
        }
        else
        {
-               ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Can't determine maximum number of open sockets: %s", strerror(errno));
-               std::cout << "ERROR: Can't determine maximum number of open sockets: " << strerror(errno) << std::endl;
-               ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE);
+               // MAX_DESCRIPTORS is mainly used for display purposes, it's not a problem that getrlimit() failed
+               MAX_DESCRIPTORS = -1;
        }
 }
 
@@ -174,7 +168,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];
 
@@ -191,7 +185,7 @@ int SocketEngine::DispatchEvents()
 
                if (revents & POLLHUP)
                {
-                       eh->HandleEvent(EVENT_ERROR, 0);
+                       eh->OnEventHandlerError(0);
                        continue;
                }
 
@@ -202,14 +196,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;
@@ -223,7 +217,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();
                }
        }