Loading src/quic.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ #include <cstdio> #include <cmath> #define QUIC_DBG(fmt, ...) do {} while(0) #define QUIC_DBG(fmt, ...) do { fprintf(stderr, "QUIC: " fmt "\n", ##__VA_ARGS__); } while(0) namespace netplus { Loading Loading @@ -221,25 +221,32 @@ void quic::generateConnectionId(std::vector<uint8_t>& cid, size_t len) { ssize_t quic::sendPacket(const uint8_t* data, size_t len) { if (_Socket < 0) { QUIC_DBG("sendPacket: _Socket < 0, dropping %zu bytes", len); return -1; } QUIC_DBG("sendPacket: len=%zu parent=%p _Socket=%d", len, (void*)_parent, _Socket); for (int attempt = 0; attempt < 5; ++attempt) { buffer send_buf(reinterpret_cast<const char*>(data), len); try { size_t sent; if (_parent != nullptr) { QUIC_DBG("sendPacket: sendTo (child) attempt=%d", attempt); sent = udp::sendTo(send_buf, MSG_DONTWAIT); } else { QUIC_DBG("sendPacket: sendData (server) attempt=%d", attempt); sent = udp::sendData(send_buf, MSG_DONTWAIT); } QUIC_DBG("sendPacket: sent=%zu", sent); if (sent > 0) { _last_activity = std::chrono::steady_clock::now(); } return static_cast<ssize_t>(sent); } catch (NetException& e) { QUIC_DBG("sendPacket: exception attempt=%d type=%d", attempt, e.getErrorType()); // EAGAIN/EWOULDBLOCK — retry after brief pause if (e.getErrorType() == NetException::Note && attempt < 4) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); Loading Loading
src/quic.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -41,7 +41,7 @@ #include <cstdio> #include <cmath> #define QUIC_DBG(fmt, ...) do {} while(0) #define QUIC_DBG(fmt, ...) do { fprintf(stderr, "QUIC: " fmt "\n", ##__VA_ARGS__); } while(0) namespace netplus { Loading Loading @@ -221,25 +221,32 @@ void quic::generateConnectionId(std::vector<uint8_t>& cid, size_t len) { ssize_t quic::sendPacket(const uint8_t* data, size_t len) { if (_Socket < 0) { QUIC_DBG("sendPacket: _Socket < 0, dropping %zu bytes", len); return -1; } QUIC_DBG("sendPacket: len=%zu parent=%p _Socket=%d", len, (void*)_parent, _Socket); for (int attempt = 0; attempt < 5; ++attempt) { buffer send_buf(reinterpret_cast<const char*>(data), len); try { size_t sent; if (_parent != nullptr) { QUIC_DBG("sendPacket: sendTo (child) attempt=%d", attempt); sent = udp::sendTo(send_buf, MSG_DONTWAIT); } else { QUIC_DBG("sendPacket: sendData (server) attempt=%d", attempt); sent = udp::sendData(send_buf, MSG_DONTWAIT); } QUIC_DBG("sendPacket: sent=%zu", sent); if (sent > 0) { _last_activity = std::chrono::steady_clock::now(); } return static_cast<ssize_t>(sent); } catch (NetException& e) { QUIC_DBG("sendPacket: exception attempt=%d type=%d", attempt, e.getErrorType()); // EAGAIN/EWOULDBLOCK — retry after brief pause if (e.getErrorType() == NetException::Note && attempt < 4) { std::this_thread::sleep_for(std::chrono::milliseconds(1)); Loading