Loading src/event/iocp.cpp +13 −13 Changes for src/event/iocp.cpp: 13 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -256,45 +256,45 @@ namespace netplus { } auto start_read = [&](client* ctx) { // IMPORTANT: this must schedule a new overlapped recv (your tcp::recvData does that) ctx->CurCon->csock->recvData(ctx->RecvBuf, 0); }; auto start_write = [&](client* ctx) { con& c = *ctx->CurCon; // Try to flush as much as possible right now. while (!c.SendData.empty()) { buffer out(c.SendData.data(), c.SendData.size() > BLOCKSIZE ? BLOCKSIZE : c.SendData.size()); std::min<size_t>(BLOCKSIZE, c.SendData.size())); size_t consumed = 0; try { consumed = c.csock->sendData(out, 0); // returns PLAINTEXT consumed consumed = c.csock->sendData(out, 0); // PLAINTEXT consumed } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { // would-block / pending -> wait for IOCP send completion ctx->State = IO_WRITE_STATE; return; } throw e; throw; } if (consumed == 0) { // SSL may be flushing internal pending TLS record; wait for completion ctx->State = IO_WRITE_STATE; return; } // erase plaintext that is now owned by ssl internal buffers/record builder if (consumed > c.SendData.size()) { NetException e; e[NetException::Error] << "IOCP: sendData consumed > SendData.size()"; e[NetException::Error] << "IOCP: sendData over-consumed"; throw e; } c.SendData.erase(c.SendData.begin(), c.SendData.begin() + consumed); c.SendData.erase(c.SendData.begin(), c.SendData.begin() + consumed); } // queue empty: let protocol layer append more (ONCE) ctx->api->ResponseEvent(c, /*tid*/0, /*args*/0); // If ResponseEvent produced more data -> keep writing, else go back to read // Let protocol append more ONCE ctx->api->ResponseEvent(c, tid, args); if (!c.SendData.empty()) { ctx->State = IO_WRITE_STATE; start_write(ctx); Loading Loading
src/event/iocp.cpp +13 −13 Changes for src/event/iocp.cpp: 13 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -256,45 +256,45 @@ namespace netplus { } auto start_read = [&](client* ctx) { // IMPORTANT: this must schedule a new overlapped recv (your tcp::recvData does that) ctx->CurCon->csock->recvData(ctx->RecvBuf, 0); }; auto start_write = [&](client* ctx) { con& c = *ctx->CurCon; // Try to flush as much as possible right now. while (!c.SendData.empty()) { buffer out(c.SendData.data(), c.SendData.size() > BLOCKSIZE ? BLOCKSIZE : c.SendData.size()); std::min<size_t>(BLOCKSIZE, c.SendData.size())); size_t consumed = 0; try { consumed = c.csock->sendData(out, 0); // returns PLAINTEXT consumed consumed = c.csock->sendData(out, 0); // PLAINTEXT consumed } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { // would-block / pending -> wait for IOCP send completion ctx->State = IO_WRITE_STATE; return; } throw e; throw; } if (consumed == 0) { // SSL may be flushing internal pending TLS record; wait for completion ctx->State = IO_WRITE_STATE; return; } // erase plaintext that is now owned by ssl internal buffers/record builder if (consumed > c.SendData.size()) { NetException e; e[NetException::Error] << "IOCP: sendData consumed > SendData.size()"; e[NetException::Error] << "IOCP: sendData over-consumed"; throw e; } c.SendData.erase(c.SendData.begin(), c.SendData.begin() + consumed); c.SendData.erase(c.SendData.begin(), c.SendData.begin() + consumed); } // queue empty: let protocol layer append more (ONCE) ctx->api->ResponseEvent(c, /*tid*/0, /*args*/0); // If ResponseEvent produced more data -> keep writing, else go back to read // Let protocol append more ONCE ctx->api->ResponseEvent(c, tid, args); if (!c.SendData.empty()) { ctx->State = IO_WRITE_STATE; start_write(ctx); Loading