Commit 613e1b96 authored by jan.koester's avatar jan.koester
Browse files

test

parent 44a01dca
Loading
Loading
Loading
Loading
+9 −3
Changes for src/event/iocp.cpp: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -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();
@@ -107,7 +107,7 @@ namespace netplus {

				pClientContext->CurCon->csock->setNonBlock();

				AssociateWithIOCP(pClientContext);
				AssociateWithIOCP(pClientContext->CurCon->csock->fd(), pClientContext);
			}
			catch (NetException& e) {
				delete pClientContext;
@@ -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
@@ -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
@@ -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
		}