Commit 70d9b4c6 authored by jan.koester's avatar jan.koester
Browse files

test

parent 6b072c87
Loading
Loading
Loading
Loading
+3 −9
Changes for src/event/iocp.cpp: 3 added lines, 9 removed lines.
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ namespace netplus {
		}

		void AcceptConnection(LPFN_ACCEPTEX lpfnAcceptEx, int tid, ULONG_PTR args) {
			std::shared_ptr<client> pClientContext(new client(g_eventapi),delete client);
			std::shared_ptr<client> pClientContext(new client(g_eventapi), std::default_delete<client>());

			if (g_serversocket->_Type == TCP)
				pClientContext->CurCon->csock = std::make_shared <tcp>();
@@ -262,8 +262,7 @@ namespace netplus {

					switch (pClientContext->State) {
						case IO_WRITE_STATE: {
							pClientContext->cltmtx.lock();

							std::lock_guard<std::mutex> clock(pClientContext->cltmtx);
							eargs->event->ResponseEvent(curCon, tid, args);
	
							ULONG ssize = curCon->SendData.size() < BLOCKSIZE ? (ULONG)curCon->SendData.size() : BLOCKSIZE;
@@ -272,11 +271,9 @@ namespace netplus {
							curCon->SendData.resize(ret);
							if (curCon->SendData.empty())
								pClientContext->State = IO_READ_STATE;
							pClientContext->cltmtx.unlock();
						}break;
						case IO_READ_STATE: {
							pClientContext->cltmtx.lock();

							std::lock_guard<std::mutex> clock(pClientContext->cltmtx);
							std::shared_ptr<char[]> buf(new char[BLOCKSIZE], std::default_delete<char[]>());
							size_t recv = curCon->csock->recvData(buf.get(), BLOCKSIZE, 0);
							curCon->RecvData.append(buf.get(), recv);
@@ -284,7 +281,6 @@ namespace netplus {
							eargs->event->RequestEvent(curCon, tid, args);
							if (!curCon->SendData.empty())
								pClientContext->State = IO_WRITE_STATE;
							pClientContext->cltmtx.unlock();
						}break;
						case IO_CLOSE_STATE: {
							eargs->evpoll->RemoveFromClientList(pClientContext);
@@ -296,13 +292,11 @@ namespace netplus {
					if (e.getErrorType() != NetException::Note) {
						pClientContext->State = IO_CLOSE_STATE;
					}
					pClientContext->cltmtx.unlock();
					continue;
				}
				catch (...) {
					std::cerr << "unknown error close coonection !" << std::endl;
					pClientContext->State = IO_CLOSE_STATE;
					pClientContext->cltmtx.unlock();
					continue;
				}