Loading src/crypto/tls.h +1 −1 Changes for src/crypto/tls.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ namespace netplus { }; // --- Buffer Management --- bool hasBufferedData() const { return !rx_tcp_buf.empty(); } bool hasBufferedData() const { return !rx_tcp_buf.empty() || recv_off < rx_record_buf.size(); } void pushReceivedData(const uint8_t* data, size_t len) { rx_tcp_buf.insert(rx_tcp_buf.end(), data, data + len); } Loading src/event/epoll.cpp +29 −2 Changes for src/event/epoll.cpp: 29 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -318,9 +318,12 @@ namespace netplus { } else { // Step 1: EPOLLIN - buffer transport data // Use a dedicated buffer so recvBuf.size stays // at BLOCKSIZE for the application-data loop. if ((events & EPOLLIN) && !needClose) { try { c->csock->prime_recv(recvBuf, 0); buffer primeBuf(BLOCKSIZE); c->csock->prime_recv(primeBuf, 0); } catch (NetException& e) { if (e.getErrorType() != NetException::Note) throw; } Loading Loading @@ -390,6 +393,11 @@ namespace netplus { size_t rcv = 0; bool wouldBlock = false; // Reset buffer size — recvData/prime_recv // shrink data.size to the actual bytes returned, // which would throttle subsequent reads. recvBuf.size = BLOCKSIZE; try { rcv = c->csock->recvData(recvBuf, 0); } catch (NetException& e) { Loading @@ -408,8 +416,27 @@ namespace netplus { evconnection->RequestEvent(*c, tid, args); } if (wouldBlock) { // The TLS layer may hold a partial record // in rx_tcp_buf but can't decrypt it yet. // Pull more raw TCP data so the record can // be completed without waiting for EPOLLIN // (which won't fire if the kernel buffer is // already drained by a previous prime_recv). bool gotMore = false; try { buffer prBuf(BLOCKSIZE); size_t pr = c->csock->prime_recv(prBuf, 0); if (pr > 0) gotMore = true; } catch (NetException&) { // EAGAIN / would-block — no more kernel data } if (!gotMore) break; continue; // retry recvData with the new raw bytes } // Continue only if there are more buffered records if (wouldBlock || rcv == 0 || !c->csock->hasBufferedData()) if (rcv == 0 || !c->csock->hasBufferedData()) break; } Loading Loading
src/crypto/tls.h +1 −1 Changes for src/crypto/tls.h: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -63,7 +63,7 @@ namespace netplus { }; // --- Buffer Management --- bool hasBufferedData() const { return !rx_tcp_buf.empty(); } bool hasBufferedData() const { return !rx_tcp_buf.empty() || recv_off < rx_record_buf.size(); } void pushReceivedData(const uint8_t* data, size_t len) { rx_tcp_buf.insert(rx_tcp_buf.end(), data, data + len); } Loading
src/event/epoll.cpp +29 −2 Changes for src/event/epoll.cpp: 29 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -318,9 +318,12 @@ namespace netplus { } else { // Step 1: EPOLLIN - buffer transport data // Use a dedicated buffer so recvBuf.size stays // at BLOCKSIZE for the application-data loop. if ((events & EPOLLIN) && !needClose) { try { c->csock->prime_recv(recvBuf, 0); buffer primeBuf(BLOCKSIZE); c->csock->prime_recv(primeBuf, 0); } catch (NetException& e) { if (e.getErrorType() != NetException::Note) throw; } Loading Loading @@ -390,6 +393,11 @@ namespace netplus { size_t rcv = 0; bool wouldBlock = false; // Reset buffer size — recvData/prime_recv // shrink data.size to the actual bytes returned, // which would throttle subsequent reads. recvBuf.size = BLOCKSIZE; try { rcv = c->csock->recvData(recvBuf, 0); } catch (NetException& e) { Loading @@ -408,8 +416,27 @@ namespace netplus { evconnection->RequestEvent(*c, tid, args); } if (wouldBlock) { // The TLS layer may hold a partial record // in rx_tcp_buf but can't decrypt it yet. // Pull more raw TCP data so the record can // be completed without waiting for EPOLLIN // (which won't fire if the kernel buffer is // already drained by a previous prime_recv). bool gotMore = false; try { buffer prBuf(BLOCKSIZE); size_t pr = c->csock->prime_recv(prBuf, 0); if (pr > 0) gotMore = true; } catch (NetException&) { // EAGAIN / would-block — no more kernel data } if (!gotMore) break; continue; // retry recvData with the new raw bytes } // Continue only if there are more buffered records if (wouldBlock || rcv == 0 || !c->csock->hasBufferedData()) if (rcv == 0 || !c->csock->hasBufferedData()) break; } Loading