Loading src/event/iocp.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -515,6 +515,8 @@ namespace netplus { INFINITE ); lpIOContext = (poll::PPER_IO_CONTEXT)lpOverlapped; switch (lpIOContext->IOOperation) { case poll::ClientIoAccept: Loading Loading @@ -578,8 +580,7 @@ namespace netplus { args->evpoll->CloseClient(lpAcceptSocketContext, FALSE); throw e; } } else { } else { // // AcceptEx completes but doesn't read any data so we need to post Loading @@ -596,15 +597,19 @@ namespace netplus { &dwRecvNumBytes, &dwFlags, &lpAcceptSocketContext->pIOContext->Overlapped, NULL); if (nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError())) { NetException e; e[NetException::Note] << "WSARecv() failed: " << WSAGetLastError(); args->evpoll->CloseClient(lpAcceptSocketContext, FALSE); delete lpAcceptSocketContext->CurCon->csock; lpAcceptSocketContext->CurCon->csock = nullptr; throw e; } } args->event->ConnectEvent(lpPerSocketContext->CurCon, tid, args); args->event->RequestEvent(lpPerSocketContext->CurCon, tid, args); // //Time to post another outstanding AcceptEx // Loading Loading @@ -640,6 +645,7 @@ namespace netplus { delete lpAcceptSocketContext->CurCon->csock; lpAcceptSocketContext->CurCon->csock = nullptr; } args->event->RequestEvent(lpPerSocketContext->CurCon, tid, args); break; case poll::ClientIoWrite: Loading Loading @@ -696,6 +702,7 @@ namespace netplus { } break; } args->event->ResponseEvent(lpPerSocketContext->CurCon, tid, args); } } catch (NetException &e) { if (e.getErrorType() == NetException::Note || NetException::Warning) Loading @@ -718,8 +725,6 @@ namespace netplus { throw exp; } _ServerSocket->listen(); ::CreateIoCompletionPort((HANDLE)_ServerSocket->fd(), iocp, (u_long)0, 0); LPFN_ACCEPTEX lpfnAcceptEx = NULL; Loading Loading @@ -764,6 +769,8 @@ namespace netplus { } } WSAResetEvent(evpoll.g_hCleanupEvent[0]); for (auto i = threadpool.begin(); i != threadpool.end(); ++i) { i->join(); } Loading Loading
src/event/iocp.cpp +12 −5 Original line number Diff line number Diff line Loading @@ -515,6 +515,8 @@ namespace netplus { INFINITE ); lpIOContext = (poll::PPER_IO_CONTEXT)lpOverlapped; switch (lpIOContext->IOOperation) { case poll::ClientIoAccept: Loading Loading @@ -578,8 +580,7 @@ namespace netplus { args->evpoll->CloseClient(lpAcceptSocketContext, FALSE); throw e; } } else { } else { // // AcceptEx completes but doesn't read any data so we need to post Loading @@ -596,15 +597,19 @@ namespace netplus { &dwRecvNumBytes, &dwFlags, &lpAcceptSocketContext->pIOContext->Overlapped, NULL); if (nRet == SOCKET_ERROR && (ERROR_IO_PENDING != WSAGetLastError())) { NetException e; e[NetException::Note] << "WSARecv() failed: " << WSAGetLastError(); args->evpoll->CloseClient(lpAcceptSocketContext, FALSE); delete lpAcceptSocketContext->CurCon->csock; lpAcceptSocketContext->CurCon->csock = nullptr; throw e; } } args->event->ConnectEvent(lpPerSocketContext->CurCon, tid, args); args->event->RequestEvent(lpPerSocketContext->CurCon, tid, args); // //Time to post another outstanding AcceptEx // Loading Loading @@ -640,6 +645,7 @@ namespace netplus { delete lpAcceptSocketContext->CurCon->csock; lpAcceptSocketContext->CurCon->csock = nullptr; } args->event->RequestEvent(lpPerSocketContext->CurCon, tid, args); break; case poll::ClientIoWrite: Loading Loading @@ -696,6 +702,7 @@ namespace netplus { } break; } args->event->ResponseEvent(lpPerSocketContext->CurCon, tid, args); } } catch (NetException &e) { if (e.getErrorType() == NetException::Note || NetException::Warning) Loading @@ -718,8 +725,6 @@ namespace netplus { throw exp; } _ServerSocket->listen(); ::CreateIoCompletionPort((HANDLE)_ServerSocket->fd(), iocp, (u_long)0, 0); LPFN_ACCEPTEX lpfnAcceptEx = NULL; Loading Loading @@ -764,6 +769,8 @@ namespace netplus { } } WSAResetEvent(evpoll.g_hCleanupEvent[0]); for (auto i = threadpool.begin(); i != threadpool.end(); ++i) { i->join(); } Loading