Loading src/event/iocp.cpp +8 −6 Changes for src/event/iocp.cpp: 8 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -104,9 +104,7 @@ 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()) { g_ClientContext.erase(it); Loading Loading @@ -281,18 +279,22 @@ namespace netplus { }break; case IO_CLOSE_STATE: { WSACloseEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); closesocket(pClientContext->CurCon->csock->fd()); 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 +8 −6 Changes for src/event/iocp.cpp: 8 added lines, 6 removed lines. Original line number Diff line number Diff line Loading @@ -104,9 +104,7 @@ 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()) { g_ClientContext.erase(it); Loading Loading @@ -281,18 +279,22 @@ namespace netplus { }break; case IO_CLOSE_STATE: { WSACloseEvent(pClientContext->CurCon->csock->_Overlapped.hEvent); closesocket(pClientContext->CurCon->csock->fd()); 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