nghttpx: Compile without UDP_SEGMENT

This commit is contained in:
Tatsuhiro Tsujikawa 2021-08-22 19:01:30 +09:00
parent 7de71b29a0
commit 102d960106
2 changed files with 25 additions and 2 deletions

View File

@ -638,6 +638,7 @@ int Http3Upstream::write_streams() {
bufpos += nwrite; bufpos += nwrite;
#ifdef UDP_SEGMENT
if (pktcnt == 0) { if (pktcnt == 0) {
ngtcp2_path_copy(&prev_ps.path, &ps.path); ngtcp2_path_copy(&prev_ps.path, &ps.path);
} else if (!ngtcp2_path_eq(&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; return 0;
} }
#else // !UDP_SEGMENT
quic_send_packet(static_cast<UpstreamAddr *>(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; return 0;

View File

@ -210,8 +210,11 @@ int quic_send_packet(const UpstreamAddr *faddr, const sockaddr *remote_sa,
msg.msg_iov = &msg_iov; msg.msg_iov = &msg_iov;
msg.msg_iovlen = 1; msg.msg_iovlen = 1;
uint8_t uint8_t msg_ctrl[
msg_ctrl[CMSG_SPACE(sizeof(uint16_t)) + CMSG_SPACE(sizeof(in6_pktinfo))]; #ifdef UDP_SEGMENT
CMSG_SPACE(sizeof(uint16_t)) +
#endif // UDP_SEGMENT
CMSG_SPACE(sizeof(in6_pktinfo))];
memset(msg_ctrl, 0, sizeof(msg_ctrl)); memset(msg_ctrl, 0, sizeof(msg_ctrl));
@ -251,6 +254,7 @@ int quic_send_packet(const UpstreamAddr *faddr, const sockaddr *remote_sa,
assert(0); assert(0);
} }
#ifdef UDP_SEGMENT
if (gso_size && datalen > gso_size) { if (gso_size && datalen > gso_size) {
controllen += CMSG_SPACE(sizeof(uint16_t)); controllen += CMSG_SPACE(sizeof(uint16_t));
cm = CMSG_NXTHDR(&msg, cm); 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)); cm->cmsg_len = CMSG_LEN(sizeof(uint16_t));
*(reinterpret_cast<uint16_t *>(CMSG_DATA(cm))) = gso_size; *(reinterpret_cast<uint16_t *>(CMSG_DATA(cm))) = gso_size;
} }
#endif // UDP_SEGMENT
msg.msg_controllen = controllen; msg.msg_controllen = controllen;