diff options
Diffstat (limited to 'lib/vquic/ngtcp2.c')
-rw-r--r-- | lib/vquic/ngtcp2.c | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/lib/vquic/ngtcp2.c b/lib/vquic/ngtcp2.c index 3b401ef15..e1882dafc 100644 --- a/lib/vquic/ngtcp2.c +++ b/lib/vquic/ngtcp2.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -90,7 +90,7 @@ struct h3out { static CURLcode ng_process_ingress(struct connectdata *conn, curl_socket_t sockfd, struct quicsocket *qs); -static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, +static CURLcode ng_flush_egress(struct Curl_easy *data, int sockfd, struct quicsocket *qs); static int cb_h3_acked_stream_data(nghttp3_conn *conn, int64_t stream_id, size_t datalen, void *user_data, @@ -843,9 +843,10 @@ int Curl_quic_ver(char *p, size_t len) ng2->version_str, ht3->version_str); } -static int ng_getsock(struct connectdata *conn, curl_socket_t *socks) +static int ng_getsock(struct Curl_easy *data, struct connectdata *conn, + curl_socket_t *socks) { - struct SingleRequest *k = &conn->data->req; + struct SingleRequest *k = &data->req; int bitmap = GETSOCK_BLANK; socks[0] = conn->sock[FIRSTSOCKET]; @@ -861,12 +862,6 @@ static int ng_getsock(struct connectdata *conn, curl_socket_t *socks) return bitmap; } -static int ng_perform_getsock(const struct connectdata *conn, - curl_socket_t *socks) -{ - return ng_getsock((struct connectdata *)conn, socks); -} - static void qs_disconnect(struct quicsocket *qs) { int i; @@ -904,18 +899,22 @@ void Curl_quic_disconnect(struct connectdata *conn, qs_disconnect(&conn->hequic[tempindex]); } -static CURLcode ng_disconnect(struct connectdata *conn, +static CURLcode ng_disconnect(struct Curl_easy *data, + struct connectdata *conn, bool dead_connection) { (void)dead_connection; + (void)data; Curl_quic_disconnect(conn, 0); Curl_quic_disconnect(conn, 1); return CURLE_OK; } -static unsigned int ng_conncheck(struct connectdata *conn, +static unsigned int ng_conncheck(struct Curl_easy *data, + struct connectdata *conn, unsigned int checks_to_perform) { + (void)data; (void)conn; (void)checks_to_perform; return CONNRESULT_NONE; @@ -933,7 +932,7 @@ static const struct Curl_handler Curl_handler_http3 = { ng_getsock, /* proto_getsock */ ng_getsock, /* doing_getsock */ ZERO_NULL, /* domore_getsock */ - ng_perform_getsock, /* perform_getsock */ + ng_getsock, /* perform_getsock */ ng_disconnect, /* disconnect */ ZERO_NULL, /* readwrite */ ng_conncheck, /* connection_check */ @@ -1235,14 +1234,15 @@ static size_t drain_overflow_buffer(struct HTTP *stream) } /* incoming data frames on the h3 stream */ -static ssize_t ngh3_stream_recv(struct connectdata *conn, +static ssize_t ngh3_stream_recv(struct Curl_easy *data, int sockindex, char *buf, size_t buffersize, CURLcode *curlcode) { + struct connectdata *conn = data->conn; curl_socket_t sockfd = conn->sock[sockindex]; - struct HTTP *stream = conn->data->req.p.http; + struct HTTP *stream = data->req.p.http; struct quicsocket *qs = conn->quic; if(!stream->memlen) { @@ -1261,7 +1261,7 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn, *curlcode = CURLE_RECV_ERROR; return -1; } - if(ng_flush_egress(conn, sockfd, qs)) { + if(ng_flush_egress(data, sockfd, qs)) { *curlcode = CURLE_SEND_ERROR; return -1; } @@ -1277,7 +1277,7 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn, /* extend the stream window with the data we're consuming and send out any additional packets to tell the server that we can receive more */ extend_stream_window(qs->qconn, stream); - if(ng_flush_egress(conn, sockfd, qs)) { + if(ng_flush_egress(data, sockfd, qs)) { *curlcode = CURLE_SEND_ERROR; return -1; } @@ -1289,7 +1289,7 @@ static ssize_t ngh3_stream_recv(struct connectdata *conn, return 0; } - infof(conn->data, "ngh3_stream_recv returns 0 bytes and EAGAIN\n"); + infof(data, "ngh3_stream_recv returns 0 bytes and EAGAIN\n"); *curlcode = CURLE_AGAIN; return -1; } @@ -1382,10 +1382,11 @@ static ssize_t cb_h3_readfunction(nghttp3_conn *conn, int64_t stream_id, field list. */ #define AUTHORITY_DST_IDX 3 -static CURLcode http_request(struct connectdata *conn, const void *mem, +static CURLcode http_request(struct Curl_easy *data, const void *mem, size_t len) { - struct HTTP *stream = conn->data->req.p.http; + struct connectdata *conn = data->conn; + struct HTTP *stream = data->req.p.http; size_t nheader; size_t i; size_t authority_idx; @@ -1393,7 +1394,6 @@ static CURLcode http_request(struct connectdata *conn, const void *mem, char *end, *line_end; struct quicsocket *qs = conn->quic; CURLcode result = CURLE_OK; - struct Curl_easy *data = conn->data; nghttp3_nv *nva = NULL; int64_t stream3_id; int rc; @@ -1401,7 +1401,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem, rc = ngtcp2_conn_open_bidi_stream(qs->qconn, &stream3_id, NULL); if(rc) { - failf(conn->data, "can get bidi streams"); + failf(data, "can get bidi streams"); result = CURLE_SEND_ERROR; goto fail; } @@ -1587,8 +1587,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem, stream->h3out = h3out; rc = nghttp3_conn_submit_request(qs->h3conn, stream->stream3_id, - nva, nheader, &data_reader, - conn->data); + nva, nheader, &data_reader, data); if(rc) { result = CURLE_SEND_ERROR; goto fail; @@ -1598,9 +1597,7 @@ static CURLcode http_request(struct connectdata *conn, const void *mem, default: stream->upload_left = 0; /* nothing left to send */ rc = nghttp3_conn_submit_request(qs->h3conn, stream->stream3_id, - nva, nheader, - NULL, /* no body! */ - conn->data); + nva, nheader, NULL, data); if(rc) { result = CURLE_SEND_ERROR; goto fail; @@ -1619,19 +1616,20 @@ fail: free(nva); return result; } -static ssize_t ngh3_stream_send(struct connectdata *conn, +static ssize_t ngh3_stream_send(struct Curl_easy *data, int sockindex, const void *mem, size_t len, CURLcode *curlcode) { ssize_t sent; + struct connectdata *conn = data->conn; struct quicsocket *qs = conn->quic; curl_socket_t sockfd = conn->sock[sockindex]; - struct HTTP *stream = conn->data->req.p.http; + struct HTTP *stream = data->req.p.http; if(!stream->h3req) { - CURLcode result = http_request(conn, mem, len); + CURLcode result = http_request(data, mem, len); if(result) { *curlcode = CURLE_SEND_ERROR; return -1; @@ -1639,7 +1637,7 @@ static ssize_t ngh3_stream_send(struct connectdata *conn, sent = len; } else { - H3BUGF(infof(conn->data, "ngh3_stream_send() wants to send %zd bytes\n", + H3BUGF(infof(data, "ngh3_stream_send() wants to send %zd bytes\n", len)); if(!stream->upload_len) { stream->upload_mem = mem; @@ -1653,7 +1651,7 @@ static ssize_t ngh3_stream_send(struct connectdata *conn, } } - if(ng_flush_egress(conn, sockfd, qs)) { + if(ng_flush_egress(data, sockfd, qs)) { *curlcode = CURLE_SEND_ERROR; return -1; } @@ -1689,7 +1687,7 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, if(result) goto error; - result = ng_flush_egress(conn, sockfd, qs); + result = ng_flush_egress(conn->data, sockfd, qs); if(result) goto error; @@ -1749,7 +1747,8 @@ static CURLcode ng_process_ingress(struct connectdata *conn, return CURLE_OK; } -static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, +static CURLcode ng_flush_egress(struct Curl_easy *data, + int sockfd, struct quicsocket *qs) { int rv; @@ -1783,7 +1782,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, rv = ngtcp2_conn_handle_expiry(qs->qconn, ts); if(rv != 0) { - failf(conn->data, "ngtcp2_conn_handle_expiry returned error: %s", + failf(data, "ngtcp2_conn_handle_expiry returned error: %s", ngtcp2_strerror(rv)); return CURLE_SEND_ERROR; } @@ -1796,7 +1795,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, veccnt = nghttp3_conn_writev_stream(qs->h3conn, &stream_id, &fin, vec, sizeof(vec) / sizeof(vec[0])); if(veccnt < 0) { - failf(conn->data, "nghttp3_conn_writev_stream returned error: %s", + failf(data, "nghttp3_conn_writev_stream returned error: %s", nghttp3_strerror((int)veccnt)); return CURLE_SEND_ERROR; } @@ -1817,7 +1816,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, assert(ndatalen == -1); rv = nghttp3_conn_block_stream(qs->h3conn, stream_id); if(rv != 0) { - failf(conn->data, + failf(data, "nghttp3_conn_block_stream returned error: %s\n", nghttp3_strerror(rv)); return CURLE_SEND_ERROR; @@ -1829,7 +1828,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, rv = nghttp3_conn_add_write_offset(qs->h3conn, stream_id, ndatalen); if(rv != 0) { - failf(conn->data, + failf(data, "nghttp3_conn_add_write_offset returned error: %s\n", nghttp3_strerror(rv)); return CURLE_SEND_ERROR; @@ -1838,7 +1837,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, } else { assert(ndatalen == -1); - failf(conn->data, "ngtcp2_conn_writev_stream returned error: %s", + failf(data, "ngtcp2_conn_writev_stream returned error: %s", ngtcp2_strerror((int)outlen)); return CURLE_SEND_ERROR; } @@ -1852,7 +1851,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, outlen = ngtcp2_conn_write_pkt(qs->qconn, &ps.path, NULL, out, pktlen, ts); if(outlen < 0) { - failf(conn->data, "ngtcp2_conn_write_pkt returned error: %s", + failf(data, "ngtcp2_conn_write_pkt returned error: %s", ngtcp2_strerror((int)outlen)); return CURLE_SEND_ERROR; } @@ -1871,7 +1870,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, break; } else { - failf(conn->data, "send() returned %zd (errno %d)", sent, + failf(data, "send() returned %zd (errno %d)", sent, SOCKERRNO); return CURLE_SEND_ERROR; } @@ -1886,7 +1885,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd, else { timeout = expiry - ts; } - Curl_expire(conn->data, timeout / NGTCP2_MILLISECONDS, EXPIRE_QUIC); + Curl_expire(data, timeout / NGTCP2_MILLISECONDS, EXPIRE_QUIC); } return CURLE_OK; |