Loading src/event/epoll.cpp +2 −19 Original line number Diff line number Diff line Loading @@ -285,14 +285,11 @@ namespace netplus { buffer buf(BLOCKSIZE); size_t rcv = 0; std::cerr << "[EPOLL] Attempting to read raw TCP data..." << std::endl; try { // Read raw TCP data (don't use recvData which tries to decrypt) rcv = ((netplus::tcp&)*c->csock).tcp::recvData(buf, 0); std::cerr << "[EPOLL] Read " << rcv << " bytes from socket" << std::endl; } catch (NetException& e) { if (e.getErrorType() == NetException::Note){ std::cerr << "[EPOLL] tcp::recvData threw Note (EAGAIN/EWOULDBLOCK)" << std::endl; // No data available right now - just continue to handshake // (it will re-arm socket when needed) rcv = 0; Loading @@ -301,10 +298,7 @@ namespace netplus { } } if (rcv == 0) { std::cerr << "[EPOLL] No TCP data available (would block or EOF)" << std::endl; } else { std::cerr << "[EPOLL] Received " << rcv << " raw TCP bytes for handshake" << std::endl; if (rcv > 0) { // Put raw TLS data into _rx_tcp_buf via pushReceivedData() c->csock->pushReceivedData((const uint8_t*)buf.data.buf, rcv); } Loading @@ -312,14 +306,11 @@ namespace netplus { // Step 2: Try handshake (with buffered TLS data) if (!c->csock->getHandshakeDone() && !needClose) { std::cerr << "[EPOLL] BEFORE handshake_after_accept: handshakeDone=" << c->csock->getHandshakeDone() << std::endl; try { c->csock->handshake_after_accept(); } catch (NetException& e) { if (e.getErrorType() != NetException::Note) throw; std::cerr << "[EPOLL] handshake_after_accept returned Note" << std::endl; } std::cerr << "[EPOLL] AFTER handshake_after_accept: handshakeDone=" << c->csock->getHandshakeDone() << std::endl; // Flush any pending write data if (c->csock->hasPendingWrite()) { Loading Loading @@ -369,11 +360,9 @@ namespace netplus { // Step 3: Handle application data (only after handshake) if ((events & EPOLLIN) && c->csock->getHandshakeDone() && !needClose) { // First, read raw TCP data into TLS buffer std::cerr << "[EPOLL] Application data phase: reading raw TCP data..." << std::endl; try { buffer buf(BLOCKSIZE); size_t rcv = ((netplus::tcp&)*c->csock).tcp::recvData(buf, 0); std::cerr << "[EPOLL] Read " << rcv << " raw TCP bytes for application data" << std::endl; if (rcv > 0) { c->csock->pushReceivedData((const uint8_t*)buf.data.buf, rcv); } Loading @@ -381,22 +370,18 @@ namespace netplus { if (e.getErrorType() != NetException::Note) { throw; } std::cerr << "[EPOLL] No more TCP data available (would block)" << std::endl; // No more TCP data available (would block) } // Now try to decrypt application data from the TLS buffer if (c->csock->hasBufferedData()) { buffer buf(BLOCKSIZE); size_t rcv = 0; std::cerr << "[EPOLL] Calling recvData for decrypted application data" << std::endl; try { rcv = c->csock->recvData(buf, 0); std::cerr << "[EPOLL] recvData returned " << rcv << " decrypted bytes" << std::endl; } catch (NetException& e) { std::cerr << "[EPOLL] recvData threw exception type=" << e.getErrorType() << " msg=" << e.what() << std::endl; if (e.getErrorType() == NetException::Note){ std::cerr << "[EPOLL] Not ready for data, re-arming" << std::endl; rearm.disarm(); setpollEventsFd(fd, EPOLLIN | EPOLLRDHUP | EPOLLONESHOT); return; Loading @@ -405,10 +390,8 @@ namespace netplus { } if (rcv == 0) { std::cerr << "[EPOLL] recvData returned 0, peer closed" << std::endl; needClose = true; } else { std::cerr << "[EPOLL] Appending " << rcv << " bytes to RecvData" << std::endl; c->RecvData.append(buf.data.buf, rcv); evconnection->RequestEvent(*c, tid, args); } Loading src/ssl.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -1631,8 +1631,6 @@ void netplus::ssl::handshake_after_accept(){ std::cerr << "[SSL] ===== handshake_after_accept ENTER state=" << (int)_hs_state << " _handshakeDone=" << _handshakeDone << std::endl; std::cerr.flush(); #endif std::cerr << "[SSL] ===== handshake_after_accept ENTER state=" << (int)_hs_state << " _handshakeDone=" << _handshakeDone << std::endl; std::cerr.flush(); auto throwSSL = [&](int type, const std::string& msg) { netplus::NetException e; Loading Loading @@ -4436,7 +4434,6 @@ void netplus::ssl::_tls13_send_record(uint8_t inner_type, } void netplus::ssl::resetTLS() { std::cerr << "[SSL] resetTLS ENTER: fd=" << this->fd() << std::endl; // MUST be false so next handshake is treated as fresh _handshakeStarted = false; Loading @@ -4456,8 +4453,6 @@ void netplus::ssl::resetTLS() { _recv_seq = 0; _handshakeDone = false; std::cerr << "[SSL] resetTLS: after reset, _handshakeDone=" << _handshakeDone << " _hs_state=" << (int)_hs_state << std::endl; _handshake_transcript.clear(); _clientRandom.clear(); _serverRandom.clear(); Loading Loading
src/event/epoll.cpp +2 −19 Original line number Diff line number Diff line Loading @@ -285,14 +285,11 @@ namespace netplus { buffer buf(BLOCKSIZE); size_t rcv = 0; std::cerr << "[EPOLL] Attempting to read raw TCP data..." << std::endl; try { // Read raw TCP data (don't use recvData which tries to decrypt) rcv = ((netplus::tcp&)*c->csock).tcp::recvData(buf, 0); std::cerr << "[EPOLL] Read " << rcv << " bytes from socket" << std::endl; } catch (NetException& e) { if (e.getErrorType() == NetException::Note){ std::cerr << "[EPOLL] tcp::recvData threw Note (EAGAIN/EWOULDBLOCK)" << std::endl; // No data available right now - just continue to handshake // (it will re-arm socket when needed) rcv = 0; Loading @@ -301,10 +298,7 @@ namespace netplus { } } if (rcv == 0) { std::cerr << "[EPOLL] No TCP data available (would block or EOF)" << std::endl; } else { std::cerr << "[EPOLL] Received " << rcv << " raw TCP bytes for handshake" << std::endl; if (rcv > 0) { // Put raw TLS data into _rx_tcp_buf via pushReceivedData() c->csock->pushReceivedData((const uint8_t*)buf.data.buf, rcv); } Loading @@ -312,14 +306,11 @@ namespace netplus { // Step 2: Try handshake (with buffered TLS data) if (!c->csock->getHandshakeDone() && !needClose) { std::cerr << "[EPOLL] BEFORE handshake_after_accept: handshakeDone=" << c->csock->getHandshakeDone() << std::endl; try { c->csock->handshake_after_accept(); } catch (NetException& e) { if (e.getErrorType() != NetException::Note) throw; std::cerr << "[EPOLL] handshake_after_accept returned Note" << std::endl; } std::cerr << "[EPOLL] AFTER handshake_after_accept: handshakeDone=" << c->csock->getHandshakeDone() << std::endl; // Flush any pending write data if (c->csock->hasPendingWrite()) { Loading Loading @@ -369,11 +360,9 @@ namespace netplus { // Step 3: Handle application data (only after handshake) if ((events & EPOLLIN) && c->csock->getHandshakeDone() && !needClose) { // First, read raw TCP data into TLS buffer std::cerr << "[EPOLL] Application data phase: reading raw TCP data..." << std::endl; try { buffer buf(BLOCKSIZE); size_t rcv = ((netplus::tcp&)*c->csock).tcp::recvData(buf, 0); std::cerr << "[EPOLL] Read " << rcv << " raw TCP bytes for application data" << std::endl; if (rcv > 0) { c->csock->pushReceivedData((const uint8_t*)buf.data.buf, rcv); } Loading @@ -381,22 +370,18 @@ namespace netplus { if (e.getErrorType() != NetException::Note) { throw; } std::cerr << "[EPOLL] No more TCP data available (would block)" << std::endl; // No more TCP data available (would block) } // Now try to decrypt application data from the TLS buffer if (c->csock->hasBufferedData()) { buffer buf(BLOCKSIZE); size_t rcv = 0; std::cerr << "[EPOLL] Calling recvData for decrypted application data" << std::endl; try { rcv = c->csock->recvData(buf, 0); std::cerr << "[EPOLL] recvData returned " << rcv << " decrypted bytes" << std::endl; } catch (NetException& e) { std::cerr << "[EPOLL] recvData threw exception type=" << e.getErrorType() << " msg=" << e.what() << std::endl; if (e.getErrorType() == NetException::Note){ std::cerr << "[EPOLL] Not ready for data, re-arming" << std::endl; rearm.disarm(); setpollEventsFd(fd, EPOLLIN | EPOLLRDHUP | EPOLLONESHOT); return; Loading @@ -405,10 +390,8 @@ namespace netplus { } if (rcv == 0) { std::cerr << "[EPOLL] recvData returned 0, peer closed" << std::endl; needClose = true; } else { std::cerr << "[EPOLL] Appending " << rcv << " bytes to RecvData" << std::endl; c->RecvData.append(buf.data.buf, rcv); evconnection->RequestEvent(*c, tid, args); } Loading
src/ssl.cpp +0 −5 Original line number Diff line number Diff line Loading @@ -1631,8 +1631,6 @@ void netplus::ssl::handshake_after_accept(){ std::cerr << "[SSL] ===== handshake_after_accept ENTER state=" << (int)_hs_state << " _handshakeDone=" << _handshakeDone << std::endl; std::cerr.flush(); #endif std::cerr << "[SSL] ===== handshake_after_accept ENTER state=" << (int)_hs_state << " _handshakeDone=" << _handshakeDone << std::endl; std::cerr.flush(); auto throwSSL = [&](int type, const std::string& msg) { netplus::NetException e; Loading Loading @@ -4436,7 +4434,6 @@ void netplus::ssl::_tls13_send_record(uint8_t inner_type, } void netplus::ssl::resetTLS() { std::cerr << "[SSL] resetTLS ENTER: fd=" << this->fd() << std::endl; // MUST be false so next handshake is treated as fresh _handshakeStarted = false; Loading @@ -4456,8 +4453,6 @@ void netplus::ssl::resetTLS() { _recv_seq = 0; _handshakeDone = false; std::cerr << "[SSL] resetTLS: after reset, _handshakeDone=" << _handshakeDone << " _hs_state=" << (int)_hs_state << std::endl; _handshake_transcript.clear(); _clientRandom.clear(); _serverRandom.clear(); Loading