Loading src/connection.h +2 −2 Changes for src/connection.h: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -159,8 +159,6 @@ namespace netplus { // all share the parent con's event_mutex. struct ConSlot { std::unique_ptr<socket> csock; condata<char> RecvData; condata<char> SendData; size_t SendOff = 0; std::atomic_bool WritePending{ false }; Loading @@ -180,6 +178,8 @@ namespace netplus { // --- Sub-connection slots --- std::vector<ConSlot> slots; // slot[0] = primary / listening socket condata<char> RecvData; condata<char> SendData; int DebugId=0; Loading src/event/epoll.cpp +20 −20 Changes for src/event/epoll.cpp: 20 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ namespace netplus { int next = EPOLLRDHUP | EPOLLIN | EPOLLONESHOT; // Check if we have pending writes if (_con->slots[0].SendData.pos < _con->slots[0].SendData.size() || _con->slots[0].csock->hasPendingWrite() if (_con->SendData.pos < _con->SendData.size() || _con->slots[0].csock->hasPendingWrite() || _con->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) next |= EPOLLOUT; Loading Loading @@ -256,7 +256,7 @@ namespace netplus { // With EPOLLONESHOT, socket must be re-armed after each event. // The batched send loop reduces re-arm syscalls by draining data // in a single epoll event rather than one chunk per event. if (ccon->slots[0].SendData.pos < ccon->slots[0].SendData.size() || ccon->slots[0].csock->hasPendingWrite()) { if (ccon->SendData.pos < ccon->SendData.size() || ccon->slots[0].csock->hasPendingWrite()) { epoll_event ev{}; ev.events = EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLONESHOT; ev.data.fd = fd; Loading Loading @@ -360,10 +360,10 @@ namespace netplus { if (c->slots[0].csock->getSocketType() == sockettype::SSL) { auto *sslsock = static_cast<ssl*>(c->slots[0].csock.get()); const auto &fcb = sslsock->getFramingCallback(); if (fcb && c->slots[0].SendData.pos >= c->slots[0].SendData.size()) { if (fcb && c->SendData.pos >= c->SendData.size()) { std::string init = fcb(sslsock->getSelectedAlpn(), 0, "", ""); if (!init.empty()) { c->slots[0].SendData.append(init.data(), init.size()); c->SendData.append(init.data(), init.size()); } } } Loading Loading @@ -397,7 +397,7 @@ namespace netplus { // True EOF — peer closed the connection needClose = true; } else if (rcv > 0) { c->slots[0].RecvData.append(recvBuf.data.buf, rcv); c->RecvData.append(recvBuf.data.buf, rcv); evconnection->RequestEvent(*c, tid, args); } Loading Loading @@ -429,7 +429,7 @@ namespace netplus { // Always attempt to send if there is data queued // (browsers require the server's HTTP/2 SETTINGS before // sending their request, so we must not wait for EPOLLOUT) if ((c->slots[0].SendData.pos < c->slots[0].SendData.size() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if ((c->SendData.pos < c->SendData.size() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if (c->slots[0].csock->hasPendingWrite()) { try { c->slots[0].csock->flush_out(); Loading @@ -447,10 +447,10 @@ namespace netplus { // This significantly improves throughput for large files by // reducing epoll_ctl system call overhead bool sendBlockedWouldBlock = false; while (c->slots[0].SendData.pos < c->slots[0].SendData.size() && !sendBlockedWouldBlock && !needClose) { size_t remaining = c->slots[0].SendData.size() - c->slots[0].SendData.pos; while (c->SendData.pos < c->SendData.size() && !sendBlockedWouldBlock && !needClose) { size_t remaining = c->SendData.size() - c->SendData.pos; size_t sendlen = std::min((size_t)BLOCKSIZE, remaining); buffer out(c->slots[0].SendData.data() + c->slots[0].SendData.pos, sendlen); buffer out(c->SendData.data() + c->SendData.pos, sendlen); size_t consumed = 0; try { Loading @@ -468,15 +468,15 @@ namespace netplus { if (consumed > 0) { // Advance position instead of erasing from the front // (erase from vector front is O(n) due to element shift). c->slots[0].SendData.pos += consumed; if (c->slots[0].SendData.pos >= c->slots[0].SendData.size()) { c->SendData.pos += consumed; if (c->SendData.pos >= c->SendData.size()) { // All data consumed — clear and reset c->slots[0].SendData.clear(); c->slots[0].SendData.pos = 0; } else if (c->slots[0].SendData.pos > BLOCKSIZE * 4) { c->SendData.clear(); c->SendData.pos = 0; } else if (c->SendData.pos > BLOCKSIZE * 4) { // Compact only when waste exceeds threshold c->slots[0].SendData.erase(c->slots[0].SendData.begin(), c->slots[0].SendData.begin() + c->slots[0].SendData.pos); c->slots[0].SendData.pos = 0; c->SendData.erase(c->SendData.begin(), c->SendData.begin() + c->SendData.pos); c->SendData.pos = 0; } } else { // No progress made, socket likely full Loading @@ -485,13 +485,13 @@ namespace netplus { } // Send blocked, guard will re-arm with EPOLLOUT if (sendBlockedWouldBlock && c->slots[0].SendData.pos < c->slots[0].SendData.size()) { if (sendBlockedWouldBlock && c->SendData.pos < c->SendData.size()) { return; } if (c->slots[0].SendData.pos >= c->slots[0].SendData.size() && !c->slots[0].csock->hasPendingWrite()) { c->slots[0].SendData.clear(); c->slots[0].SendData.pos = 0; if (c->SendData.pos >= c->SendData.size() && !c->slots[0].csock->hasPendingWrite()) { c->SendData.clear(); c->SendData.pos = 0; evconnection->ResponseEvent(*c, tid, args); } } 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 @@ -148,19 +148,19 @@ namespace netplus { static bool try_post_send(event* ev, EventState* /*st*/, con& c, int tid) { if (c.slots[0].Closing.load()) return false; if (c.slots[0].WritePending.load()) return false; if (c.slots[0].SendData.empty()) return false; if (c.SendData.empty()) return false; c.slots[0].WritePending.store(true); try { size_t sendlen = std::min<size_t>(c.slots[0].SendData.size(), BLOCKSIZE); const char* ptr = c.slots[0].SendData.data(); size_t sendlen = std::min<size_t>(c.SendData.size(), BLOCKSIZE); const char* ptr = c.SendData.data(); buffer sbuf(ptr, sendlen); size_t consumed = c.slots[0].csock->sendData(sbuf, 0); if (consumed > 0) { c.slots[0].SendData.erase(c.slots[0].SendData.begin(), c.slots[0].SendData.begin() + consumed); c.SendData.erase(c.SendData.begin(), c.SendData.begin() + consumed); } if (c.slots[0].csock->hasPendingWrite()) { Loading @@ -169,7 +169,7 @@ namespace netplus { c.slots[0].WritePending.store(false); if (!c.slots[0].SendData.empty()) { if (!c.SendData.empty()) { return try_post_send(ev, nullptr, c, tid); } Loading Loading @@ -379,10 +379,10 @@ namespace netplus { // Post-handshake framing callback (e.g. HTTP/2 SETTINGS) if (auto *sslsock = dynamic_cast<ssl*>(owner->slots[0].csock.get())) { const auto &fcb = sslsock->getFramingCallback(); if (fcb && owner->slots[0].SendData.empty()) { if (fcb && owner->SendData.empty()) { std::string init = fcb(sslsock->getSelectedAlpn(), 0, "", ""); if (!init.empty()) { owner->slots[0].SendData.append(init.data(), init.size()); owner->SendData.append(init.data(), init.size()); } } } Loading @@ -406,7 +406,7 @@ namespace netplus { if (wouldBlock || decLen == 0) break; owner->slots[0].RecvData.append(decrypted.data.buf, decLen); owner->RecvData.append(decrypted.data.buf, decLen); ev->RequestEvent(*owner, tid, (ULONG_PTR)decLen); if (!owner->slots[0].csock->hasBufferedData()) break; Loading Loading @@ -490,25 +490,25 @@ namespace netplus { } try { if (owner->slots[0].SendData.empty() && !owner->slots[0].csock->hasPendingWrite()) { if (owner->SendData.empty() && !owner->slots[0].csock->hasPendingWrite()) { ev->ResponseEvent(*owner, tid, (ULONG_PTR)bytes); } if (!owner->slots[0].SendData.empty()) { if (!owner->SendData.empty()) { bool posted = try_post_send(ev, st, *owner, tid); if (posted) continue; } // App requested re-trigger (e.g. upstream data not yet available) if (owner->slots[0].SendData.empty() && owner->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) { if (owner->SendData.empty() && owner->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) { ev->ResponseEvent(*owner, tid, 0); if (!owner->slots[0].SendData.empty()) { if (!owner->SendData.empty()) { bool posted = try_post_send(ev, st, *owner, tid); if (posted) continue; } } if (owner->slots[0].SendData.empty() && !owner->slots[0].csock->hasPendingWrite() && !owner->slots[0].Closing.load()) { if (owner->SendData.empty() && !owner->slots[0].csock->hasPendingWrite() && !owner->slots[0].Closing.load()) { try { post_recv(st, *owner); } catch (...) {} } } catch (...) { Loading src/event/poll.cpp +12 −12 Changes for src/event/poll.cpp: 12 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ namespace netplus { next |= SELECT_EV_WRITE; } else { next |= SELECT_EV_READ; if (!_con->slots[0].SendData.empty() || _con->slots[0].csock->hasPendingWrite() if (!_con->SendData.empty() || _con->slots[0].csock->hasPendingWrite() || _con->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) next |= SELECT_EV_WRITE; if (_con->slots[0].csock->hasBufferedData()) Loading Loading @@ -348,7 +348,7 @@ namespace netplus { evconnection->ConnectEvent(*ccon, tid, args); // If ConnectEvent queued data, also watch for write readiness if (!ccon->slots[0].SendData.empty() || ccon->slots[0].csock->hasPendingWrite()) { if (!ccon->SendData.empty() || ccon->slots[0].csock->hasPendingWrite()) { FD_SET(fd, &_masterWriteSet); } Loading Loading @@ -427,10 +427,10 @@ namespace netplus { // Post-handshake framing callback (e.g. HTTP/2 SETTINGS) if (auto *sslsock = dynamic_cast<ssl*>(c->slots[0].csock.get())) { const auto &fcb = sslsock->getFramingCallback(); if (fcb && c->slots[0].SendData.empty()) { if (fcb && c->SendData.empty()) { std::string init = fcb(sslsock->getSelectedAlpn(), 0, "", ""); if (!init.empty()) { c->slots[0].SendData.append(init.data(), init.size()); c->SendData.append(init.data(), init.size()); } } } Loading @@ -456,7 +456,7 @@ namespace netplus { if (!wouldBlock && rcv == 0) { needClose = true; } else if (rcv > 0) { c->slots[0].RecvData.append(buf.data.buf, rcv); c->RecvData.append(buf.data.buf, rcv); evconnection->RequestEvent(*c, tid, args); } Loading @@ -465,7 +465,7 @@ namespace netplus { } // Step 4: Flush and send if ((!c->slots[0].SendData.empty() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if ((!c->SendData.empty() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if (c->slots[0].csock->hasPendingWrite()) { try { c->slots[0].csock->flush_out(); Loading @@ -479,9 +479,9 @@ namespace netplus { } } if (!c->slots[0].SendData.empty()) { size_t sendlen = std::min((size_t)BLOCKSIZE, c->slots[0].SendData.size()); buffer out(c->slots[0].SendData.data(), sendlen); if (!c->SendData.empty()) { size_t sendlen = std::min((size_t)BLOCKSIZE, c->SendData.size()); buffer out(c->SendData.data(), sendlen); size_t consumed = 0; try { Loading @@ -498,11 +498,11 @@ namespace netplus { } if (consumed > 0) { c->slots[0].SendData.erase(c->slots[0].SendData.begin(), c->slots[0].SendData.begin() + consumed); c->SendData.erase(c->SendData.begin(), c->SendData.begin() + consumed); } } if (c->slots[0].SendData.empty() && !c->slots[0].csock->hasPendingWrite()) { if (c->SendData.empty() && !c->slots[0].csock->hasPendingWrite()) { evconnection->ResponseEvent(*c, tid, args); } } Loading @@ -511,7 +511,7 @@ namespace netplus { } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { int ev = SELECT_EV_READ; if (c->slots[0].csock->hasPendingWrite() || !c->slots[0].SendData.empty()) if (c->slots[0].csock->hasPendingWrite() || !c->SendData.empty()) ev |= SELECT_EV_WRITE; rearm.disarm(); setpollEventsFd(fd, ev); Loading test/http.cpp +1 −1 Changes for test/http.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class MyServer : public event { resp += "\r\n"; resp += body; curcon.slots[0].SendData.append(resp.data(), resp.size()); curcon.SendData.append(resp.data(), resp.size()); } void ResponseEvent(con &curcon, const int tid, ULONG_PTR args) override { Loading Loading
src/connection.h +2 −2 Changes for src/connection.h: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -159,8 +159,6 @@ namespace netplus { // all share the parent con's event_mutex. struct ConSlot { std::unique_ptr<socket> csock; condata<char> RecvData; condata<char> SendData; size_t SendOff = 0; std::atomic_bool WritePending{ false }; Loading @@ -180,6 +178,8 @@ namespace netplus { // --- Sub-connection slots --- std::vector<ConSlot> slots; // slot[0] = primary / listening socket condata<char> RecvData; condata<char> SendData; int DebugId=0; Loading
src/event/epoll.cpp +20 −20 Changes for src/event/epoll.cpp: 20 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -106,7 +106,7 @@ namespace netplus { int next = EPOLLRDHUP | EPOLLIN | EPOLLONESHOT; // Check if we have pending writes if (_con->slots[0].SendData.pos < _con->slots[0].SendData.size() || _con->slots[0].csock->hasPendingWrite() if (_con->SendData.pos < _con->SendData.size() || _con->slots[0].csock->hasPendingWrite() || _con->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) next |= EPOLLOUT; Loading Loading @@ -256,7 +256,7 @@ namespace netplus { // With EPOLLONESHOT, socket must be re-armed after each event. // The batched send loop reduces re-arm syscalls by draining data // in a single epoll event rather than one chunk per event. if (ccon->slots[0].SendData.pos < ccon->slots[0].SendData.size() || ccon->slots[0].csock->hasPendingWrite()) { if (ccon->SendData.pos < ccon->SendData.size() || ccon->slots[0].csock->hasPendingWrite()) { epoll_event ev{}; ev.events = EPOLLIN | EPOLLOUT | EPOLLRDHUP | EPOLLONESHOT; ev.data.fd = fd; Loading Loading @@ -360,10 +360,10 @@ namespace netplus { if (c->slots[0].csock->getSocketType() == sockettype::SSL) { auto *sslsock = static_cast<ssl*>(c->slots[0].csock.get()); const auto &fcb = sslsock->getFramingCallback(); if (fcb && c->slots[0].SendData.pos >= c->slots[0].SendData.size()) { if (fcb && c->SendData.pos >= c->SendData.size()) { std::string init = fcb(sslsock->getSelectedAlpn(), 0, "", ""); if (!init.empty()) { c->slots[0].SendData.append(init.data(), init.size()); c->SendData.append(init.data(), init.size()); } } } Loading Loading @@ -397,7 +397,7 @@ namespace netplus { // True EOF — peer closed the connection needClose = true; } else if (rcv > 0) { c->slots[0].RecvData.append(recvBuf.data.buf, rcv); c->RecvData.append(recvBuf.data.buf, rcv); evconnection->RequestEvent(*c, tid, args); } Loading Loading @@ -429,7 +429,7 @@ namespace netplus { // Always attempt to send if there is data queued // (browsers require the server's HTTP/2 SETTINGS before // sending their request, so we must not wait for EPOLLOUT) if ((c->slots[0].SendData.pos < c->slots[0].SendData.size() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if ((c->SendData.pos < c->SendData.size() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if (c->slots[0].csock->hasPendingWrite()) { try { c->slots[0].csock->flush_out(); Loading @@ -447,10 +447,10 @@ namespace netplus { // This significantly improves throughput for large files by // reducing epoll_ctl system call overhead bool sendBlockedWouldBlock = false; while (c->slots[0].SendData.pos < c->slots[0].SendData.size() && !sendBlockedWouldBlock && !needClose) { size_t remaining = c->slots[0].SendData.size() - c->slots[0].SendData.pos; while (c->SendData.pos < c->SendData.size() && !sendBlockedWouldBlock && !needClose) { size_t remaining = c->SendData.size() - c->SendData.pos; size_t sendlen = std::min((size_t)BLOCKSIZE, remaining); buffer out(c->slots[0].SendData.data() + c->slots[0].SendData.pos, sendlen); buffer out(c->SendData.data() + c->SendData.pos, sendlen); size_t consumed = 0; try { Loading @@ -468,15 +468,15 @@ namespace netplus { if (consumed > 0) { // Advance position instead of erasing from the front // (erase from vector front is O(n) due to element shift). c->slots[0].SendData.pos += consumed; if (c->slots[0].SendData.pos >= c->slots[0].SendData.size()) { c->SendData.pos += consumed; if (c->SendData.pos >= c->SendData.size()) { // All data consumed — clear and reset c->slots[0].SendData.clear(); c->slots[0].SendData.pos = 0; } else if (c->slots[0].SendData.pos > BLOCKSIZE * 4) { c->SendData.clear(); c->SendData.pos = 0; } else if (c->SendData.pos > BLOCKSIZE * 4) { // Compact only when waste exceeds threshold c->slots[0].SendData.erase(c->slots[0].SendData.begin(), c->slots[0].SendData.begin() + c->slots[0].SendData.pos); c->slots[0].SendData.pos = 0; c->SendData.erase(c->SendData.begin(), c->SendData.begin() + c->SendData.pos); c->SendData.pos = 0; } } else { // No progress made, socket likely full Loading @@ -485,13 +485,13 @@ namespace netplus { } // Send blocked, guard will re-arm with EPOLLOUT if (sendBlockedWouldBlock && c->slots[0].SendData.pos < c->slots[0].SendData.size()) { if (sendBlockedWouldBlock && c->SendData.pos < c->SendData.size()) { return; } if (c->slots[0].SendData.pos >= c->slots[0].SendData.size() && !c->slots[0].csock->hasPendingWrite()) { c->slots[0].SendData.clear(); c->slots[0].SendData.pos = 0; if (c->SendData.pos >= c->SendData.size() && !c->slots[0].csock->hasPendingWrite()) { c->SendData.clear(); c->SendData.pos = 0; evconnection->ResponseEvent(*c, tid, args); } } 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 @@ -148,19 +148,19 @@ namespace netplus { static bool try_post_send(event* ev, EventState* /*st*/, con& c, int tid) { if (c.slots[0].Closing.load()) return false; if (c.slots[0].WritePending.load()) return false; if (c.slots[0].SendData.empty()) return false; if (c.SendData.empty()) return false; c.slots[0].WritePending.store(true); try { size_t sendlen = std::min<size_t>(c.slots[0].SendData.size(), BLOCKSIZE); const char* ptr = c.slots[0].SendData.data(); size_t sendlen = std::min<size_t>(c.SendData.size(), BLOCKSIZE); const char* ptr = c.SendData.data(); buffer sbuf(ptr, sendlen); size_t consumed = c.slots[0].csock->sendData(sbuf, 0); if (consumed > 0) { c.slots[0].SendData.erase(c.slots[0].SendData.begin(), c.slots[0].SendData.begin() + consumed); c.SendData.erase(c.SendData.begin(), c.SendData.begin() + consumed); } if (c.slots[0].csock->hasPendingWrite()) { Loading @@ -169,7 +169,7 @@ namespace netplus { c.slots[0].WritePending.store(false); if (!c.slots[0].SendData.empty()) { if (!c.SendData.empty()) { return try_post_send(ev, nullptr, c, tid); } Loading Loading @@ -379,10 +379,10 @@ namespace netplus { // Post-handshake framing callback (e.g. HTTP/2 SETTINGS) if (auto *sslsock = dynamic_cast<ssl*>(owner->slots[0].csock.get())) { const auto &fcb = sslsock->getFramingCallback(); if (fcb && owner->slots[0].SendData.empty()) { if (fcb && owner->SendData.empty()) { std::string init = fcb(sslsock->getSelectedAlpn(), 0, "", ""); if (!init.empty()) { owner->slots[0].SendData.append(init.data(), init.size()); owner->SendData.append(init.data(), init.size()); } } } Loading @@ -406,7 +406,7 @@ namespace netplus { if (wouldBlock || decLen == 0) break; owner->slots[0].RecvData.append(decrypted.data.buf, decLen); owner->RecvData.append(decrypted.data.buf, decLen); ev->RequestEvent(*owner, tid, (ULONG_PTR)decLen); if (!owner->slots[0].csock->hasBufferedData()) break; Loading Loading @@ -490,25 +490,25 @@ namespace netplus { } try { if (owner->slots[0].SendData.empty() && !owner->slots[0].csock->hasPendingWrite()) { if (owner->SendData.empty() && !owner->slots[0].csock->hasPendingWrite()) { ev->ResponseEvent(*owner, tid, (ULONG_PTR)bytes); } if (!owner->slots[0].SendData.empty()) { if (!owner->SendData.empty()) { bool posted = try_post_send(ev, st, *owner, tid); if (posted) continue; } // App requested re-trigger (e.g. upstream data not yet available) if (owner->slots[0].SendData.empty() && owner->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) { if (owner->SendData.empty() && owner->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) { ev->ResponseEvent(*owner, tid, 0); if (!owner->slots[0].SendData.empty()) { if (!owner->SendData.empty()) { bool posted = try_post_send(ev, st, *owner, tid); if (posted) continue; } } if (owner->slots[0].SendData.empty() && !owner->slots[0].csock->hasPendingWrite() && !owner->slots[0].Closing.load()) { if (owner->SendData.empty() && !owner->slots[0].csock->hasPendingWrite() && !owner->slots[0].Closing.load()) { try { post_recv(st, *owner); } catch (...) {} } } catch (...) { Loading
src/event/poll.cpp +12 −12 Changes for src/event/poll.cpp: 12 added lines, 12 removed lines. Original line number Diff line number Diff line Loading @@ -150,7 +150,7 @@ namespace netplus { next |= SELECT_EV_WRITE; } else { next |= SELECT_EV_READ; if (!_con->slots[0].SendData.empty() || _con->slots[0].csock->hasPendingWrite() if (!_con->SendData.empty() || _con->slots[0].csock->hasPendingWrite() || _con->slots[0].ResponsePending.exchange(false, std::memory_order_relaxed)) next |= SELECT_EV_WRITE; if (_con->slots[0].csock->hasBufferedData()) Loading Loading @@ -348,7 +348,7 @@ namespace netplus { evconnection->ConnectEvent(*ccon, tid, args); // If ConnectEvent queued data, also watch for write readiness if (!ccon->slots[0].SendData.empty() || ccon->slots[0].csock->hasPendingWrite()) { if (!ccon->SendData.empty() || ccon->slots[0].csock->hasPendingWrite()) { FD_SET(fd, &_masterWriteSet); } Loading Loading @@ -427,10 +427,10 @@ namespace netplus { // Post-handshake framing callback (e.g. HTTP/2 SETTINGS) if (auto *sslsock = dynamic_cast<ssl*>(c->slots[0].csock.get())) { const auto &fcb = sslsock->getFramingCallback(); if (fcb && c->slots[0].SendData.empty()) { if (fcb && c->SendData.empty()) { std::string init = fcb(sslsock->getSelectedAlpn(), 0, "", ""); if (!init.empty()) { c->slots[0].SendData.append(init.data(), init.size()); c->SendData.append(init.data(), init.size()); } } } Loading @@ -456,7 +456,7 @@ namespace netplus { if (!wouldBlock && rcv == 0) { needClose = true; } else if (rcv > 0) { c->slots[0].RecvData.append(buf.data.buf, rcv); c->RecvData.append(buf.data.buf, rcv); evconnection->RequestEvent(*c, tid, args); } Loading @@ -465,7 +465,7 @@ namespace netplus { } // Step 4: Flush and send if ((!c->slots[0].SendData.empty() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if ((!c->SendData.empty() || c->slots[0].csock->hasPendingWrite()) && !needClose) { if (c->slots[0].csock->hasPendingWrite()) { try { c->slots[0].csock->flush_out(); Loading @@ -479,9 +479,9 @@ namespace netplus { } } if (!c->slots[0].SendData.empty()) { size_t sendlen = std::min((size_t)BLOCKSIZE, c->slots[0].SendData.size()); buffer out(c->slots[0].SendData.data(), sendlen); if (!c->SendData.empty()) { size_t sendlen = std::min((size_t)BLOCKSIZE, c->SendData.size()); buffer out(c->SendData.data(), sendlen); size_t consumed = 0; try { Loading @@ -498,11 +498,11 @@ namespace netplus { } if (consumed > 0) { c->slots[0].SendData.erase(c->slots[0].SendData.begin(), c->slots[0].SendData.begin() + consumed); c->SendData.erase(c->SendData.begin(), c->SendData.begin() + consumed); } } if (c->slots[0].SendData.empty() && !c->slots[0].csock->hasPendingWrite()) { if (c->SendData.empty() && !c->slots[0].csock->hasPendingWrite()) { evconnection->ResponseEvent(*c, tid, args); } } Loading @@ -511,7 +511,7 @@ namespace netplus { } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { int ev = SELECT_EV_READ; if (c->slots[0].csock->hasPendingWrite() || !c->slots[0].SendData.empty()) if (c->slots[0].csock->hasPendingWrite() || !c->SendData.empty()) ev |= SELECT_EV_WRITE; rearm.disarm(); setpollEventsFd(fd, ev); Loading
test/http.cpp +1 −1 Changes for test/http.cpp: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -29,7 +29,7 @@ class MyServer : public event { resp += "\r\n"; resp += body; curcon.slots[0].SendData.append(resp.data(), resp.size()); curcon.SendData.append(resp.data(), resp.size()); } void ResponseEvent(con &curcon, const int tid, ULONG_PTR args) override { Loading