Loading src/crypto/aes.h +2 −0 Changes for src/crypto/aes.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -43,7 +43,9 @@ extern const uint8_t S_BOX[256]; extern const uint8_t INV_S_BOX[256]; extern const uint8_t RCON[10]; // Rcon values for key expansion (only 10 needed for AES-128) extern "C" { static void aes_self_check(); } class aes { private: Loading src/event/epoll.cpp +13 −34 Changes for src/event/epoll.cpp: 13 added lines, 34 removed lines. Original line number Diff line number Diff line Loading @@ -276,8 +276,6 @@ namespace netplus { } } void WriteEventHandler(int pos, const int tid, ULONG_PTR args) { con* wcon = reinterpret_cast<con*>(_Events[pos].data.ptr); if (!wcon || !wcon->csock) return; Loading @@ -286,52 +284,33 @@ namespace netplus { if (!wcon->csock) return; try { evconnection->ResponseEvent(*wcon, tid, args); // keep writing as long as: // - app SendData has bytes OR // - ssl still has pending encrypted bytes for (;;) { // 1) If no app bytes left, flush SSL pending record by calling sendData with empty buffer if (wcon->SendData.empty()) { netplus::buffer empty((char*)nullptr, 0); // or however your buffer can represent empty size_t n = wcon->csock->sendData(empty); // If SSL still pending, we must stay in EPOLLOUT if (auto* ss = dynamic_cast<netplus::ssl*>(wcon->csock.get())) { if (ss->hasPendingWrite()) { setpollEvents(pos, EPOLLOUT | EPOLLONESHOT); return; } } // nothing pending anymore -> switch to read setpollEvents(pos, EPOLLIN | EPOLLONESHOT); return; } // IMPORTANT: do not generate new response here repeatedly. // If you want: call it once when entering write mode (optional). // evconnection->ResponseEvent(*wcon, tid, args); // 2) Normal path: send some app bytes while (!wcon->SendData.empty()) { size_t toSend = std::min<size_t>(BLOCKSIZE, wcon->SendData.size()); netplus::buffer out(wcon->SendData.data(), toSend); buffer out(wcon->SendData.data(), toSend); size_t consumed = wcon->csock->sendData(out); size_t consumed = wcon->csock->sendData(out, 0); // consumed plaintext if (consumed == 0) { // would-block or SSL is flushing an internal record // would-block OR ssl still flushing its internal pending record setpollEvents(pos, EPOLLOUT | EPOLLONESHOT); return; } wcon->SendData.erase(wcon->SendData.begin(), wcon->SendData.begin() + consumed); wcon->lasteventime = time(nullptr); } if (wcon->SendData.empty()) { evconnection->ResponseEvent(*wcon, tid, args); // loop continues and will flush SSL pending record } } // queue empty -> go back to read if(wcon->SendData.empty()) setpollEvents(pos, EPOLLIN | EPOLLONESHOT); return; } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { Loading src/event/poll.cpp +2 −7 Changes for src/event/poll.cpp: 2 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -435,9 +435,6 @@ namespace netplus { std::lock_guard<std::mutex> g(wcon->event_mutex); try { // Let protocol enqueue response bytes (headers/body/etc.) evconnection->ResponseEvent(*wcon, tid, args); for (;;) { // If app send queue is empty, we might still need to flush TLS internal record. if (wcon->SendData.empty()) { Loading Loading @@ -489,12 +486,10 @@ namespace netplus { wcon->lasteventime = time(nullptr); // If we just emptied app queue, let protocol enqueue more (chunked etc.) if (wcon->SendData.empty()) { evconnection->ResponseEvent(*wcon, tid, args); } // loop continues: keep writing until would-block } evconnection->ResponseEvent(*wcon, tid, args); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { return; Loading Loading
src/crypto/aes.h +2 −0 Changes for src/crypto/aes.h: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -43,7 +43,9 @@ extern const uint8_t S_BOX[256]; extern const uint8_t INV_S_BOX[256]; extern const uint8_t RCON[10]; // Rcon values for key expansion (only 10 needed for AES-128) extern "C" { static void aes_self_check(); } class aes { private: Loading
src/event/epoll.cpp +13 −34 Changes for src/event/epoll.cpp: 13 added lines, 34 removed lines. Original line number Diff line number Diff line Loading @@ -276,8 +276,6 @@ namespace netplus { } } void WriteEventHandler(int pos, const int tid, ULONG_PTR args) { con* wcon = reinterpret_cast<con*>(_Events[pos].data.ptr); if (!wcon || !wcon->csock) return; Loading @@ -286,52 +284,33 @@ namespace netplus { if (!wcon->csock) return; try { evconnection->ResponseEvent(*wcon, tid, args); // keep writing as long as: // - app SendData has bytes OR // - ssl still has pending encrypted bytes for (;;) { // 1) If no app bytes left, flush SSL pending record by calling sendData with empty buffer if (wcon->SendData.empty()) { netplus::buffer empty((char*)nullptr, 0); // or however your buffer can represent empty size_t n = wcon->csock->sendData(empty); // If SSL still pending, we must stay in EPOLLOUT if (auto* ss = dynamic_cast<netplus::ssl*>(wcon->csock.get())) { if (ss->hasPendingWrite()) { setpollEvents(pos, EPOLLOUT | EPOLLONESHOT); return; } } // nothing pending anymore -> switch to read setpollEvents(pos, EPOLLIN | EPOLLONESHOT); return; } // IMPORTANT: do not generate new response here repeatedly. // If you want: call it once when entering write mode (optional). // evconnection->ResponseEvent(*wcon, tid, args); // 2) Normal path: send some app bytes while (!wcon->SendData.empty()) { size_t toSend = std::min<size_t>(BLOCKSIZE, wcon->SendData.size()); netplus::buffer out(wcon->SendData.data(), toSend); buffer out(wcon->SendData.data(), toSend); size_t consumed = wcon->csock->sendData(out); size_t consumed = wcon->csock->sendData(out, 0); // consumed plaintext if (consumed == 0) { // would-block or SSL is flushing an internal record // would-block OR ssl still flushing its internal pending record setpollEvents(pos, EPOLLOUT | EPOLLONESHOT); return; } wcon->SendData.erase(wcon->SendData.begin(), wcon->SendData.begin() + consumed); wcon->lasteventime = time(nullptr); } if (wcon->SendData.empty()) { evconnection->ResponseEvent(*wcon, tid, args); // loop continues and will flush SSL pending record } } // queue empty -> go back to read if(wcon->SendData.empty()) setpollEvents(pos, EPOLLIN | EPOLLONESHOT); return; } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { Loading
src/event/poll.cpp +2 −7 Changes for src/event/poll.cpp: 2 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -435,9 +435,6 @@ namespace netplus { std::lock_guard<std::mutex> g(wcon->event_mutex); try { // Let protocol enqueue response bytes (headers/body/etc.) evconnection->ResponseEvent(*wcon, tid, args); for (;;) { // If app send queue is empty, we might still need to flush TLS internal record. if (wcon->SendData.empty()) { Loading Loading @@ -489,12 +486,10 @@ namespace netplus { wcon->lasteventime = time(nullptr); // If we just emptied app queue, let protocol enqueue more (chunked etc.) if (wcon->SendData.empty()) { evconnection->ResponseEvent(*wcon, tid, args); } // loop continues: keep writing until would-block } evconnection->ResponseEvent(*wcon, tid, args); } catch (NetException& e) { if (e.getErrorType() == NetException::Note) { return; Loading