From 96edc7954f5c2ca34587c44d0f6e46faa5492717 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 9 Mar 2022 14:16:47 +0100 Subject: [PATCH] ngtcp2: disconnect the QUIC connection proper Reported-by: mehatzri on github Reviewed-by: Tatsuhiro Tsujikawa Fixes #8534 closes #8569 --- lib/vquic/ngtcp2.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/vquic/ngtcp2.c b/lib/vquic/ngtcp2.c index aac092b8d..30596042b 100644 --- a/lib/vquic/ngtcp2.c +++ b/lib/vquic/ngtcp2.c @@ -858,8 +858,23 @@ static int ng_getsock(struct Curl_easy *data, struct connectdata *conn, static void qs_disconnect(struct quicsocket *qs) { + char buffer[NGTCP2_MAX_UDP_PAYLOAD_SIZE]; + ngtcp2_tstamp ts; + ngtcp2_ssize rc; if(!qs->conn) /* already closed */ return; + ts = timestamp(); + rc = ngtcp2_conn_write_connection_close(qs->qconn, NULL, /* path */ + NULL, /* pkt_info */ + (uint8_t *)buffer, sizeof(buffer), + 0, /* error_code */ + NULL, 0, /* reason + len */ + ts); + if(rc > 0) { + while((send(qs->conn->sock[FIRSTSOCKET], buffer, rc, 0) == -1) && + SOCKERRNO == EINTR); + } + qs->conn = NULL; if(qs->qlogfd != -1) { close(qs->qlogfd);