]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_iocp.cpp
All working now, with any luck
[user/henk/code/inspircd.git] / src / socketengines / socketengine_iocp.cpp
index 84371ca3acbb24b3fae15e5ff569dd90fa1ef3dd..9b7dd63c751e3be43189c20df85548da1675f20c 100644 (file)
@@ -2,7 +2,7 @@
  *       | Inspire Internet Relay Chat Daemon |
  *       +------------------------------------+
  *
- *  InspIRCd: (C) 2002-2007 InspIRCd Development Team
+ *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
  * See: http://www.inspircd.org/wiki/index.php/Credits
  *
  * This program is free but copyrighted software; see
@@ -20,12 +20,12 @@ IOCPEngine::IOCPEngine(InspIRCd * Instance) : SocketEngine(Instance)
        /* Create completion port */
        m_completionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, (ULONG_PTR)0, 0);
 
-        if (!m_completionPort)
+       if (!m_completionPort)
        {
-               ServerInstance->Log(SPARSE,"ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
-               ServerInstance->Log(SPARSE,"ERROR: this is a fatal error, exiting now.");
-               printf("ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
-               printf("ERROR: this is a fatal error, exiting now.");
+               ServerInstance->Log(DEFAULT, "ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
+               ServerInstance->Log(DEFAULT, "ERROR: this is a fatal error, exiting now.");
+               printf("ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.\n");
+               printf("ERROR: this is a fatal error, exiting now.\n");
                ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
        }
 
@@ -93,7 +93,7 @@ bool IOCPEngine::AddFd(EventHandler* eh)
        /* we're all good =) */
        try
        {
-               m_binding.insert( map<int, EventHandler*>::value_type( eh->GetFd(), eh ) );
+               m_binding.insert( std::map<int, EventHandler*>::value_type( eh->GetFd(), eh ) );
        }
        catch (...)
        {
@@ -302,10 +302,13 @@ int IOCPEngine::DispatchEvents()
                eh->GetExt("windows_readevent", m_readEvent);
                eh->GetExt("windows_writeevent", m_writeEvent);
 
+               TotalEvents++;
+
                switch(ov->m_event)
                {
                        case SOCKET_IO_EVENT_WRITE_READY:
                        {
+                               WriteEvents++;
                                eh->Shrink("windows_writeevent");
                                eh->HandleEvent(EVENT_WRITE, 0);
                        }
@@ -313,6 +316,7 @@ int IOCPEngine::DispatchEvents()
 
                        case SOCKET_IO_EVENT_READ_READY:
                        {
+                               ReadEvents++;
                                if(ov->m_params)
                                {
                                        // if we had params, it means we are a udp socket with a udp_overlap pointer in this long.
@@ -346,6 +350,7 @@ int IOCPEngine::DispatchEvents()
                        case SOCKET_IO_EVENT_ACCEPT:
                        {
                                /* this is kinda messy.. :/ */
+                               ReadEvents++;
                                eh->HandleEvent(EVENT_READ, ov->m_params);
                                delete ((accept_overlap*)ov->m_params);
                                eh->Shrink("windows_acceptevent");
@@ -355,6 +360,7 @@ int IOCPEngine::DispatchEvents()
 
                        case SOCKET_IO_EVENT_ERROR:
                        {
+                               ErrorEvents++;
                                eh->HandleEvent(EVENT_ERROR, ov->m_params);
                        }
                        break;
@@ -411,7 +417,7 @@ std::string IOCPEngine::GetName()
 
 EventHandler * IOCPEngine::GetRef(int fd)
 {
-       map<int, EventHandler*>::iterator itr = m_binding.find(fd);
+       std::map<int, EventHandler*>::iterator itr = m_binding.find(fd);
        return (itr == m_binding.end()) ? 0 : itr->second;
 }