diff options
Diffstat (limited to 'Utilities/cmcurl/lib/vquic/quiche.c')
-rw-r--r-- | Utilities/cmcurl/lib/vquic/quiche.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/Utilities/cmcurl/lib/vquic/quiche.c b/Utilities/cmcurl/lib/vquic/quiche.c index fd9cb8b..d0d150e 100644 --- a/Utilities/cmcurl/lib/vquic/quiche.c +++ b/Utilities/cmcurl/lib/vquic/quiche.c @@ -9,7 +9,7 @@ * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.haxx.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -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, @@ -131,7 +136,7 @@ static unsigned int quiche_conncheck(struct connectdata *conn, static CURLcode quiche_do(struct connectdata *conn, bool *done) { - struct HTTP *stream = conn->data->req.protop; + struct HTTP *stream = conn->data->req.p.http; stream->h3req = FALSE; /* not sent */ return Curl_http(conn, done); } @@ -154,6 +159,7 @@ static const struct Curl_handler Curl_handler_http3 = { quiche_conncheck, /* connection_check */ PORT_HTTP, /* defport */ CURLPROTO_HTTPS, /* protocol */ + CURLPROTO_HTTP, /* family */ PROTOPT_SSL | PROTOPT_STREAM /* flags */ }; @@ -186,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"); @@ -336,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; } @@ -357,7 +364,7 @@ static CURLcode process_ingress(struct connectdata *conn, int sockfd, break; if(recvd < 0) { - failf(conn->data, "quiche: recv() unexpectedly returned %d " + failf(conn->data, "quiche: recv() unexpectedly returned %zd " "(errno: %d, socket %d)", recvd, SOCKERRNO, sockfd); return CURLE_RECV_ERROR; } @@ -367,7 +374,7 @@ static CURLcode process_ingress(struct connectdata *conn, int sockfd, break; if(recvd < 0) { - failf(conn->data, "quiche_conn_recv() == %d", recvd); + failf(conn->data, "quiche_conn_recv() == %zd", recvd); return CURLE_RECV_ERROR; } } while(1); @@ -383,7 +390,7 @@ static CURLcode flush_egress(struct connectdata *conn, int sockfd, struct quicsocket *qs) { ssize_t sent; - static uint8_t out[1200]; + uint8_t out[1200]; int64_t timeout_ns; do { @@ -460,7 +467,7 @@ static ssize_t h3_stream_recv(struct connectdata *conn, int rc; struct h3h1header headers; struct Curl_easy *data = conn->data; - struct HTTP *stream = data->req.protop; + struct HTTP *stream = data->req.p.http; headers.dest = buf; headers.destlen = buffersize; headers.nlen = 0; @@ -548,7 +555,7 @@ static ssize_t h3_stream_send(struct connectdata *conn, ssize_t sent; struct quicsocket *qs = conn->quic; curl_socket_t sockfd = conn->sock[sockindex]; - struct HTTP *stream = conn->data->req.protop; + struct HTTP *stream = conn->data->req.p.http; if(!stream->h3req) { CURLcode result = http_request(conn, mem, len); @@ -596,7 +603,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem, { /* */ - struct HTTP *stream = conn->data->req.protop; + struct HTTP *stream = conn->data->req.p.http; size_t nheader; size_t i; size_t authority_idx; @@ -761,7 +768,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem, if(acc > MAX_ACC) { infof(data, "http_request: Warning: The cumulative length of all " - "headers exceeds %zu bytes and that could cause the " + "headers exceeds %d bytes and that could cause the " "stream to be rejected.\n", MAX_ACC); } } @@ -824,7 +831,7 @@ CURLcode Curl_quic_done_sending(struct connectdata *conn) if(conn->handler == &Curl_handler_http3) { /* only for HTTP/3 transfers */ ssize_t sent; - struct HTTP *stream = conn->data->req.protop; + struct HTTP *stream = conn->data->req.p.http; struct quicsocket *qs = conn->quic; fprintf(stderr, "!!! Curl_quic_done_sending\n"); stream->upload_done = TRUE; |