]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_iocp.cpp
Add GreenReaper and Skip to contributors
[user/henk/code/inspircd.git] / src / socketengines / socketengine_iocp.cpp
index 9b7dd63c751e3be43189c20df85548da1675f20c..c1e97ce74186f325117177b122b17b054ba09e65 100644 (file)
 
 IOCPEngine::IOCPEngine(InspIRCd * Instance) : SocketEngine(Instance)
 {
+       MAX_DESCRIPTORS = 10240;
+
        /* Create completion port */
        m_completionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, (ULONG_PTR)0, 0);
 
        if (!m_completionPort)
        {
-               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.");
+               ServerInstance->Logs->Log("SOCKET",DEFAULT, "ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
+               ServerInstance->Logs->Log("SOCKET",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);
@@ -32,6 +34,8 @@ IOCPEngine::IOCPEngine(InspIRCd * Instance) : SocketEngine(Instance)
        /* Null variables out. */
        CurrentSetSize = 0;
        EngineHandle = 0;
+       MAX_DESCRIPTORS = 10240;
+       ref = new EventHandler* [10240];
        memset(ref, 0, sizeof(EventHandler*) * MAX_DESCRIPTORS);
 }
 
@@ -40,6 +44,7 @@ IOCPEngine::~IOCPEngine()
        /* Clean up winsock and close completion port */
        CloseHandle(m_completionPort);
        WSACleanup();
+       delete[] ref;
 }
 
 bool IOCPEngine::AddFd(EventHandler* eh)
@@ -84,7 +89,7 @@ bool IOCPEngine::AddFd(EventHandler* eh)
                PostReadEvent(eh);
 
        /* log message */
-       ServerInstance->Log(DEBUG, "New fake fd: %u, real fd: %u, address 0x%p", *fake_fd, eh->GetFd(), eh);
+       ServerInstance->Logs->Log("SOCKET",DEBUG, "New fake fd: %u, real fd: %u, address 0x%p", *fake_fd, eh->GetFd(), eh);
 
        /* post a write event if there is data to be written */
        if(eh->Writeable())
@@ -123,7 +128,7 @@ bool IOCPEngine::DelFd(EventHandler* eh, bool force /* = false */)
        void* m_writeEvent = NULL;
        void* m_acceptEvent = NULL;
 
-       ServerInstance->Log(DEBUG, "Removing fake fd %u, real fd %u, address 0x%p", *fake_fd, eh->GetFd(), eh);
+       ServerInstance->Logs->Log("SOCKET",DEBUG, "Removing fake fd %u, real fd %u, address 0x%p", *fake_fd, eh->GetFd(), eh);
 
        /* Cancel pending i/o operations. */
        if (CancelIo((HANDLE)fd) == FALSE)
@@ -450,7 +455,7 @@ EventHandler * IOCPEngine::GetIntRef(int fd)
 
 int IOCPEngine::Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen)
 {
-       SOCKET s = fd->GetFd();
+       //SOCKET s = fd->GetFd();
 
        Overlapped* acceptevent = NULL;
        if (!fd->GetExt("windows_acceptevent", acceptevent))
@@ -460,7 +465,7 @@ int IOCPEngine::Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen)
        Overlapped* ovl = acceptevent;
        accept_overlap* ov = (accept_overlap*)ovl->m_params;
        
-       sockaddr_in* server_address = (sockaddr_in*)&ov->buf[10];
+       //sockaddr_in* server_address = (sockaddr_in*)&ov->buf[10];
        sockaddr_in* client_address = (sockaddr_in*)&ov->buf[38];
 
        memcpy(addr, client_address, sizeof(sockaddr_in));
@@ -479,7 +484,7 @@ int IOCPEngine::GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen
        accept_overlap* ov = (accept_overlap*)ovl->m_params;
 
        sockaddr_in* server_address = (sockaddr_in*)&ov->buf[10];
-       sockaddr_in* client_address = (sockaddr_in*)&ov->buf[38];
+       //sockaddr_in* client_address = (sockaddr_in*)&ov->buf[38];
 
        memcpy(name, server_address, sizeof(sockaddr_in));
        *namelen = sizeof(sockaddr_in);
@@ -519,3 +524,4 @@ int IOCPEngine::Close(EventHandler* fd)
        return this->Close(fd->GetFd());
 }
 
+