Coalesce EOED + client Finished in one UDP packet
@@ -1520,9 +1520,12 @@ static ssize_t conn_write_client_handshake(ngtcp2_conn *conn, uint8_t *dest,
ngtcp2_tstamp ts) {
ngtcp2_ringbuf *rb = &conn->tx_crypto_data;
ngtcp2_crypto_data *cdata;
+ ssize_t nwrite;
+ ssize_t res = 0;
+ for (;;) {
if (ngtcp2_ringbuf_len(rb) == 0) {
- return 0;
+ return res;
}
cdata = ngtcp2_ringbuf_get(rb, 0);
@@ -1538,8 +1541,25 @@ static ssize_t conn_write_client_handshake(ngtcp2_conn *conn, uint8_t *dest,
assert(0);
}
- return conn_write_handshake_pkt(conn, dest, destlen, cdata->pkt_type,
+ nwrite = conn_write_handshake_pkt(conn, dest, destlen, cdata->pkt_type,
require_padding, ts);
+ if (nwrite < 0) {
+ if (nwrite != NGTCP2_ERR_NOBUF) {
+ return nwrite;
+ }
+ if (res) {
+ return res;
+ }
+ return NGTCP2_ERR_NOBUF;
+ }
+ if (nwrite == 0) {
+ return res;
+ }
+
+ res += nwrite;
+ dest += nwrite;
+ destlen -= (size_t)nwrite;
+ }
}
static ssize_t conn_write_protected_ack_pkt(ngtcp2_conn *conn, uint8_t *dest,
