X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocketengines%2Fsocketengine_iocp.cpp;h=9ae394e5656ed1f0d917e6bae550e4f8324c9162;hb=b233d0c582a3c6f8d85b681074e4f1ac4678276d;hp=38ca235b55ba8f9472b2ac0cbc33cefa201b726a;hpb=e4acbc95b8b6cd5b28d38a2242c02e8ff4991e4a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socketengines/socketengine_iocp.cpp b/src/socketengines/socketengine_iocp.cpp index 38ca235b5..9ae394e56 100644 --- a/src/socketengines/socketengine_iocp.cpp +++ b/src/socketengines/socketengine_iocp.cpp @@ -17,21 +17,25 @@ 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) + 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->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); } /* 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()) @@ -93,7 +98,7 @@ bool IOCPEngine::AddFd(EventHandler* eh) /* we're all good =) */ try { - m_binding.insert( map::value_type( eh->GetFd(), eh ) ); + m_binding.insert( std::map::value_type( eh->GetFd(), eh ) ); } catch (...) { @@ -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) @@ -302,10 +307,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 +321,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 +355,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 +365,7 @@ int IOCPEngine::DispatchEvents() case SOCKET_IO_EVENT_ERROR: { + ErrorEvents++; eh->HandleEvent(EVENT_ERROR, ov->m_params); } break; @@ -411,7 +422,7 @@ std::string IOCPEngine::GetName() EventHandler * IOCPEngine::GetRef(int fd) { - map::iterator itr = m_binding.find(fd); + std::map::iterator itr = m_binding.find(fd); return (itr == m_binding.end()) ? 0 : itr->second; }