Loading src/event/iocp.cpp +8 −7 Changes for src/event/iocp.cpp: 8 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -104,20 +104,18 @@ namespace netplus { void RemoveFromClientList(client* pClientContext) { std::lock_guard<std::mutex> lock(g_ClientContextMutex); auto it = std::find(g_ClientContext.begin(), g_ClientContext.end(), pClientContext); if (it != g_ClientContext.end()) { if (pClientContext->cltmtx.try_lock()) { pClientContext->cltmtx.unlock(); g_ClientContext.erase(it); } } } void AcceptConnection(LPFN_ACCEPTEX lpfnAcceptEx, int tid, ULONG_PTR args) { client* pClientContext = new client(g_eventapi); if (g_serversocket->_Type == TCP) pClientContext->CurCon->csock = new tcp(); pClientContext->CurCon->csock = new tcp(-1); try { g_serversocket->accept(lpfnAcceptEx, pClientContext->CurCon->csock); Loading Loading @@ -253,8 +251,7 @@ namespace netplus { continue; } if (!pClientContext->cltmtx.try_lock()) continue; std::unique_lock<std::mutex> cltLock(pClientContext->cltmtx); try { auto& curCon = pClientContext->CurCon; Loading Loading @@ -283,6 +280,11 @@ namespace netplus { throw exp[NetException::Error] << "No incoming data !"; } }break; default: { NetException exp; exp[NetException::Error] << "Unknown IO State: " << pClientContext->State; throw exp; }break; } WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } catch (NetException& e) { Loading @@ -295,7 +297,6 @@ namespace netplus { std::cerr << "unknown error close coonection !" << std::endl; eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->cltmtx.unlock(); } // for } }; Loading Loading
src/event/iocp.cpp +8 −7 Changes for src/event/iocp.cpp: 8 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -104,20 +104,18 @@ namespace netplus { void RemoveFromClientList(client* pClientContext) { std::lock_guard<std::mutex> lock(g_ClientContextMutex); auto it = std::find(g_ClientContext.begin(), g_ClientContext.end(), pClientContext); if (it != g_ClientContext.end()) { if (pClientContext->cltmtx.try_lock()) { pClientContext->cltmtx.unlock(); g_ClientContext.erase(it); } } } void AcceptConnection(LPFN_ACCEPTEX lpfnAcceptEx, int tid, ULONG_PTR args) { client* pClientContext = new client(g_eventapi); if (g_serversocket->_Type == TCP) pClientContext->CurCon->csock = new tcp(); pClientContext->CurCon->csock = new tcp(-1); try { g_serversocket->accept(lpfnAcceptEx, pClientContext->CurCon->csock); Loading Loading @@ -253,8 +251,7 @@ namespace netplus { continue; } if (!pClientContext->cltmtx.try_lock()) continue; std::unique_lock<std::mutex> cltLock(pClientContext->cltmtx); try { auto& curCon = pClientContext->CurCon; Loading Loading @@ -283,6 +280,11 @@ namespace netplus { throw exp[NetException::Error] << "No incoming data !"; } }break; default: { NetException exp; exp[NetException::Error] << "Unknown IO State: " << pClientContext->State; throw exp; }break; } WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } catch (NetException& e) { Loading @@ -295,7 +297,6 @@ namespace netplus { std::cerr << "unknown error close coonection !" << std::endl; eargs->evpoll->RemoveFromClientList(pClientContext); } pClientContext->cltmtx.unlock(); } // for } }; Loading