summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-11-18 14:06:07 +0100
committerDaniel Stenberg <daniel@haxx.se>2020-12-02 22:50:39 +0100
commit26f682bcc40dd8e197af3f0e958b0bd070d0ec26 (patch)
treed9f625fa0444dd537c1af0cbcbbf4a737d02f643
parent2d1df660bcea0a6015f9f48a6a11fd804134faf0 (diff)
downloadcurl-26f682bcc40dd8e197af3f0e958b0bd070d0ec26.tar.gz
quiche: close the connection
Reported-by: Junho Choi Fixes #6213 Closes #6217
-rw-r--r--lib/vquic/quiche.c22
-rw-r--r--lib/vquic/quiche.h1
2 files changed, 15 insertions, 8 deletions
diff --git a/lib/vquic/quiche.c b/lib/vquic/quiche.c
index 3d9739663..d0d150e39 100644
--- a/lib/vquic/quiche.c
+++ b/lib/vquic/quiche.c
@@ -89,8 +89,17 @@ static int quiche_perform_getsock(const struct connectdata *conn,
return quiche_getsock((struct connectdata *)conn, socks);
}
-static CURLcode qs_disconnect(struct quicsocket *qs)
+static CURLcode qs_disconnect(struct connectdata *conn,
+ struct quicsocket *qs)
{
+ if(qs->conn) {
+ (void)quiche_conn_close(qs->conn, TRUE, 0, NULL, 0);
+ /* flushing the egress is not a failsafe way to deliver all the
+ outstanding packets, but we also don't want to get stuck here... */
+ (void)flush_egress(conn, qs->sockfd, qs);
+ quiche_conn_free(qs->conn);
+ qs->conn = NULL;
+ }
if(qs->h3config)
quiche_h3_config_free(qs->h3config);
if(qs->h3c)
@@ -99,10 +108,6 @@ static CURLcode qs_disconnect(struct quicsocket *qs)
quiche_config_free(qs->cfg);
qs->cfg = NULL;
}
- if(qs->conn) {
- quiche_conn_free(qs->conn);
- qs->conn = NULL;
- }
return CURLE_OK;
}
@@ -111,14 +116,14 @@ static CURLcode quiche_disconnect(struct connectdata *conn,
{
struct quicsocket *qs = conn->quic;
(void)dead_connection;
- return qs_disconnect(qs);
+ return qs_disconnect(conn, qs);
}
void Curl_quic_disconnect(struct connectdata *conn,
int tempindex)
{
if(conn->transport == TRNSPRT_QUIC)
- qs_disconnect(&conn->hequic[tempindex]);
+ qs_disconnect(conn, &conn->hequic[tempindex]);
}
static unsigned int quiche_conncheck(struct connectdata *conn,
@@ -187,6 +192,7 @@ CURLcode Curl_quic_connect(struct connectdata *conn, curl_socket_t sockfd,
(void)addr;
(void)addrlen;
+ qs->sockfd = sockfd;
qs->cfg = quiche_config_new(QUICHE_PROTOCOL_VERSION);
if(!qs->cfg) {
failf(data, "can't create quiche config");
@@ -337,7 +343,7 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, int sockindex,
return result;
error:
- qs_disconnect(qs);
+ qs_disconnect(conn, qs);
return result;
}
diff --git a/lib/vquic/quiche.h b/lib/vquic/quiche.h
index 247c1c448..d311e9988 100644
--- a/lib/vquic/quiche.h
+++ b/lib/vquic/quiche.h
@@ -41,6 +41,7 @@ struct quicsocket {
quiche_h3_conn *h3c;
quiche_h3_config *h3config;
uint8_t scid[QUICHE_MAX_CONN_ID_LEN];
+ curl_socket_t sockfd;
uint32_t version;
};