From 102d960106ffcd7d3980039f9e12e9a87a492998 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 22 Aug 2021 19:01:30 +0900 Subject: [PATCH] nghttpx: Compile without UDP_SEGMENT --- src/shrpx_http3_upstream.cc | 18 ++++++++++++++++++ src/shrpx_quic.cc | 9 +++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/shrpx_http3_upstream.cc b/src/shrpx_http3_upstream.cc index da080c0a..92a8aad6 100644 --- a/src/shrpx_http3_upstream.cc +++ b/src/shrpx_http3_upstream.cc @@ -638,6 +638,7 @@ int Http3Upstream::write_streams() { bufpos += nwrite; +#ifdef UDP_SEGMENT if (pktcnt == 0) { ngtcp2_path_copy(&prev_ps.path, &ps.path); } else if (!ngtcp2_path_eq(&prev_ps.path, &ps.path)) { @@ -674,6 +675,23 @@ int Http3Upstream::write_streams() { return 0; } +#else // !UDP_SEGMENT + quic_send_packet(static_cast(ps.path.user_data), + ps.path.remote.addr, ps.path.remote.addrlen, + ps.path.local.addr, ps.path.local.addrlen, buf.data(), + bufpos - buf.data(), 0); + + if (++pktcnt == max_pktcnt) { + ngtcp2_conn_update_pkt_tx_time(conn_, ts); + reset_idle_timer(); + + handler_->signal_write(); + + return 0; + } + + bufpos = buf.data(); +#endif // !UDP_SEGMENT } return 0; diff --git a/src/shrpx_quic.cc b/src/shrpx_quic.cc index 09f0683f..a1ea2a32 100644 --- a/src/shrpx_quic.cc +++ b/src/shrpx_quic.cc @@ -210,8 +210,11 @@ int quic_send_packet(const UpstreamAddr *faddr, const sockaddr *remote_sa, msg.msg_iov = &msg_iov; msg.msg_iovlen = 1; - uint8_t - msg_ctrl[CMSG_SPACE(sizeof(uint16_t)) + CMSG_SPACE(sizeof(in6_pktinfo))]; + uint8_t msg_ctrl[ +#ifdef UDP_SEGMENT + CMSG_SPACE(sizeof(uint16_t)) + +#endif // UDP_SEGMENT + CMSG_SPACE(sizeof(in6_pktinfo))]; memset(msg_ctrl, 0, sizeof(msg_ctrl)); @@ -251,6 +254,7 @@ int quic_send_packet(const UpstreamAddr *faddr, const sockaddr *remote_sa, assert(0); } +#ifdef UDP_SEGMENT if (gso_size && datalen > gso_size) { controllen += CMSG_SPACE(sizeof(uint16_t)); cm = CMSG_NXTHDR(&msg, cm); @@ -259,6 +263,7 @@ int quic_send_packet(const UpstreamAddr *faddr, const sockaddr *remote_sa, cm->cmsg_len = CMSG_LEN(sizeof(uint16_t)); *(reinterpret_cast(CMSG_DATA(cm))) = gso_size; } +#endif // UDP_SEGMENT msg.msg_controllen = controllen;