Loading src/event/iocp.cpp +9 −3 Changes for src/event/iocp.cpp: 9 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -84,9 +84,9 @@ namespace netplus { : g_iocp(iocp), g_eventapi(api), g_serversocket(ssock) { } void AssociateWithIOCP(client *pClientContext) { void AssociateWithIOCP(SOCKET socket,client *pClientContext) { //Associate the socket with IOCP HANDLE giocp2 = CreateIoCompletionPort((HANDLE)(pClientContext)->CurCon->csock->fd(), g_iocp,reinterpret_cast<ULONG_PTR>(pClientContext), 0); HANDLE giocp2 = CreateIoCompletionPort((HANDLE)socket, g_iocp,reinterpret_cast<ULONG_PTR>(pClientContext), 0); if (!giocp2 || g_iocp != giocp2) { DWORD err = GetLastError(); Loading @@ -107,7 +107,7 @@ namespace netplus { pClientContext->CurCon->csock->setNonBlock(); AssociateWithIOCP(pClientContext); AssociateWithIOCP(pClientContext->CurCon->csock->fd(), pClientContext); } catch (NetException& e) { delete pClientContext; Loading Loading @@ -277,6 +277,7 @@ namespace netplus { ret = curCon->csock->sendData(buf, 0); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { PostQueuedCompletionStatus(eargs->eviocp, dwBytesTransfered, lpContext, &curCon->csock->_Overlapped); continue; // Retry sending data } else { throw e; // Rethrow other exceptions Loading @@ -302,6 +303,7 @@ namespace netplus { } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { std::cout << "Note: " << e.what() << std::endl; PostQueuedCompletionStatus(eargs->eviocp,dwBytesTransfered,lpContext,&curCon->csock->_Overlapped); continue; // Retry receiving data } else { throw e; // Rethrow other exceptions Loading Loading @@ -332,6 +334,10 @@ namespace netplus { eargs->event->DisconnectEvent(*pClientContext->CurCon, tid, args); delete pClientContext->CurCon->csock; delete pClientContext; } catch (...) { eargs->event->DisconnectEvent(*pClientContext->CurCon, tid, args); delete pClientContext->CurCon->csock; delete pClientContext; } } // for } Loading Loading
src/event/iocp.cpp +9 −3 Changes for src/event/iocp.cpp: 9 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -84,9 +84,9 @@ namespace netplus { : g_iocp(iocp), g_eventapi(api), g_serversocket(ssock) { } void AssociateWithIOCP(client *pClientContext) { void AssociateWithIOCP(SOCKET socket,client *pClientContext) { //Associate the socket with IOCP HANDLE giocp2 = CreateIoCompletionPort((HANDLE)(pClientContext)->CurCon->csock->fd(), g_iocp,reinterpret_cast<ULONG_PTR>(pClientContext), 0); HANDLE giocp2 = CreateIoCompletionPort((HANDLE)socket, g_iocp,reinterpret_cast<ULONG_PTR>(pClientContext), 0); if (!giocp2 || g_iocp != giocp2) { DWORD err = GetLastError(); Loading @@ -107,7 +107,7 @@ namespace netplus { pClientContext->CurCon->csock->setNonBlock(); AssociateWithIOCP(pClientContext); AssociateWithIOCP(pClientContext->CurCon->csock->fd(), pClientContext); } catch (NetException& e) { delete pClientContext; Loading Loading @@ -277,6 +277,7 @@ namespace netplus { ret = curCon->csock->sendData(buf, 0); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { PostQueuedCompletionStatus(eargs->eviocp, dwBytesTransfered, lpContext, &curCon->csock->_Overlapped); continue; // Retry sending data } else { throw e; // Rethrow other exceptions Loading @@ -302,6 +303,7 @@ namespace netplus { } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { std::cout << "Note: " << e.what() << std::endl; PostQueuedCompletionStatus(eargs->eviocp,dwBytesTransfered,lpContext,&curCon->csock->_Overlapped); continue; // Retry receiving data } else { throw e; // Rethrow other exceptions Loading Loading @@ -332,6 +334,10 @@ namespace netplus { eargs->event->DisconnectEvent(*pClientContext->CurCon, tid, args); delete pClientContext->CurCon->csock; delete pClientContext; } catch (...) { eargs->event->DisconnectEvent(*pClientContext->CurCon, tid, args); delete pClientContext->CurCon->csock; delete pClientContext; } } // for } Loading