Loading src/event/iocp.cpp +11 −6 Changes for src/event/iocp.cpp: 11 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -104,13 +104,13 @@ namespace netplus { } void RemoveFromClientList(client* pClientContext) { std::lock(g_ClientContextMutex, pClientContext->cltmtx); std::lock_guard<std::mutex> lock1(g_ClientContextMutex, std::adopt_lock); std::lock_guard<std::mutex> lock2(pClientContext->cltmtx, std::adopt_lock); 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); delete pClientContext; } } } Loading Loading @@ -282,16 +282,21 @@ namespace netplus { case IO_CLOSE_STATE: { WSACloseEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); eargs->evpoll->RemoveFromClientList(pClientContext); }break; }continue; } WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } catch (NetException& e) { std::cerr << e.what() << std::endl; if (e.getErrorType() != NetException::Note) { pClientContext->State = IO_CLOSE_STATE; continue; } } catch (...) { std::cerr << "unknown error close coonection !" << std::endl; pClientContext->State = IO_CLOSE_STATE; continue; } WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } // for } }; Loading Loading
src/event/iocp.cpp +11 −6 Changes for src/event/iocp.cpp: 11 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -104,13 +104,13 @@ namespace netplus { } void RemoveFromClientList(client* pClientContext) { std::lock(g_ClientContextMutex, pClientContext->cltmtx); std::lock_guard<std::mutex> lock1(g_ClientContextMutex, std::adopt_lock); std::lock_guard<std::mutex> lock2(pClientContext->cltmtx, std::adopt_lock); 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); delete pClientContext; } } } Loading Loading @@ -282,16 +282,21 @@ namespace netplus { case IO_CLOSE_STATE: { WSACloseEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); eargs->evpoll->RemoveFromClientList(pClientContext); }break; }continue; } WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } catch (NetException& e) { std::cerr << e.what() << std::endl; if (e.getErrorType() != NetException::Note) { pClientContext->State = IO_CLOSE_STATE; continue; } } catch (...) { std::cerr << "unknown error close coonection !" << std::endl; pClientContext->State = IO_CLOSE_STATE; continue; } WSAResetEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); } // for } }; Loading