Commit 98d21139 authored by jan.koester's avatar jan.koester
Browse files

win fixed

parent 6b90f4ba
Loading
Loading
Loading
Loading
+18 −8
Changes for src/event/iocp.cpp: 18 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ namespace netplus {
		~client() {
		}

		size_t last_plain_consumed = 0;
		int                       State;
		eventapi                 *api;
		std::unique_ptr<con>      CurCon;
@@ -267,6 +268,7 @@ namespace netplus {
							// Switch to write state and initiate an async send
							pClientContext->State = IO_WRITE_STATE;
							buffer buf(curCon->SendData.data(), curCon->SendData.size());
							pClientContext->last_plain_consumed = curCon->csock->sendData(buf, 0);
							curCon->csock->sendData(buf);
						}
						else {
@@ -275,19 +277,27 @@ namespace netplus {
						}
					}break;
					case IO_WRITE_STATE: {
						// Erase the sent data from the buffer
						curCon->SendData.erase(curCon->SendData.begin(),curCon->SendData.begin()+dwBytesTransfered);
						const size_t consumed = pClientContext->last_plain_consumed;

						if (consumed == 0) {
							// would-block style case; just re-issue send with same plaintext again
							buffer buf(curCon->SendData.data(), curCon->SendData.size());
							pClientContext->last_plain_consumed = curCon->csock->sendData(buf, 0);
							break;
						}

						// erase PLAINTEXT, not dwBytesTransfered
						curCon->SendData.erase(curCon->SendData.begin(),
											curCon->SendData.begin() + consumed);

						eargs->event->ResponseEvent(*curCon, tid, args);

						if (!curCon->SendData.empty()) {
							// More data to send, initiate another async send
							buffer buf(curCon->SendData.data(), curCon->SendData.size());
							curCon->csock->sendData(buf);
						}
						else {
							// All data sent, switch to read state and initiate a new read
							pClientContext->last_plain_consumed = curCon->csock->sendData(buf, 0);
						} else {
							pClientContext->State = IO_READ_STATE;
							curCon->csock->recvData(pClientContext->RecvBuf);
							curCon->csock->recvData(pClientContext->RecvBuf, 0);
						}
					}break;
					default: {