Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update nghttp3 to 1.8.0 #56333

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
* control credit (both stream and connection) of underlying QUIC
* connection by that amount. It does not include the amount of data
* carried by DATA frame which contains application data (excluding
* any control or QPACK unidirectional streams) . See
* any control or QPACK unidirectional streams). See
* :type:`nghttp3_recv_data` to handle those bytes. If |fin| is
* nonzero, this is the last data from remote endpoint in this stream.
*
Expand Down Expand Up @@ -2480,8 +2480,6 @@ typedef struct nghttp3_data_reader {
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
*
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
* |stream_id| identifies unidirectional stream.
* :macro:`NGHTTP3_ERR_CONN_CLOSING`
* Connection is shutting down, and no new stream is allowed.
* :macro:`NGHTTP3_ERR_STREAM_IN_USE`
Expand Down
4 changes: 2 additions & 2 deletions deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* Version number of the nghttp3 library release.
*/
#define NGHTTP3_VERSION "1.6.0"
#define NGHTTP3_VERSION "1.8.0"

/**
* @macro
Expand All @@ -41,6 +41,6 @@
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
* becomes 0x010203.
*/
#define NGHTTP3_VERSION_NUM 0x010600
#define NGHTTP3_VERSION_NUM 0x010800

#endif /* !defined(NGHTTP3_VERSION_H) */
80 changes: 49 additions & 31 deletions deps/ngtcp2/nghttp3/lib/nghttp3_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
dynamic table capacity that QPACK encoder is willing to use. */
#define NGHTTP3_QPACK_ENCODER_MAX_DTABLE_CAPACITY 4096

nghttp3_objalloc_def(chunk, nghttp3_chunk, oplent);
nghttp3_objalloc_def(chunk, nghttp3_chunk, oplent)

/*
* conn_remote_stream_uni returns nonzero if |stream_id| is remote
Expand Down Expand Up @@ -233,12 +233,16 @@ static int conn_new(nghttp3_conn **pconn, int server, int callbacks_version,
const nghttp3_callbacks *callbacks, int settings_version,
const nghttp3_settings *settings, const nghttp3_mem *mem,
void *user_data) {
int rv;
nghttp3_conn *conn;
size_t i;
(void)callbacks_version;
(void)settings_version;

assert(settings->max_field_section_size <= NGHTTP3_VARINT_MAX);
assert(settings->qpack_max_dtable_capacity <= NGHTTP3_VARINT_MAX);
assert(settings->qpack_encoder_max_dtable_capacity <= NGHTTP3_VARINT_MAX);
assert(settings->qpack_blocked_streams <= NGHTTP3_VARINT_MAX);

if (mem == NULL) {
mem = nghttp3_mem_default();
}
Expand All @@ -254,18 +258,11 @@ static int conn_new(nghttp3_conn **pconn, int server, int callbacks_version,

nghttp3_map_init(&conn->streams, mem);

rv =
nghttp3_qpack_decoder_init(&conn->qdec, settings->qpack_max_dtable_capacity,
settings->qpack_blocked_streams, mem);
if (rv != 0) {
goto qdec_init_fail;
}
nghttp3_qpack_decoder_init(&conn->qdec, settings->qpack_max_dtable_capacity,
settings->qpack_blocked_streams, mem);

rv = nghttp3_qpack_encoder_init(
&conn->qenc, settings->qpack_encoder_max_dtable_capacity, mem);
if (rv != 0) {
goto qenc_init_fail;
}
nghttp3_qpack_encoder_init(&conn->qenc,
settings->qpack_encoder_max_dtable_capacity, mem);

nghttp3_pq_init(&conn->qpack_blocked_streams, ricnt_less, mem);

Expand All @@ -291,16 +288,6 @@ static int conn_new(nghttp3_conn **pconn, int server, int callbacks_version,
*pconn = conn;

return 0;

qenc_init_fail:
nghttp3_qpack_decoder_free(&conn->qdec);
qdec_init_fail:
nghttp3_map_free(&conn->streams);
nghttp3_objalloc_free(&conn->stream_objalloc);
nghttp3_objalloc_free(&conn->out_chunk_objalloc);
nghttp3_mem_free(mem, conn);

return rv;
}

int nghttp3_conn_client_new_versioned(nghttp3_conn **pconn,
Expand Down Expand Up @@ -399,6 +386,9 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
size_t bidi_nproc;
int rv;

assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);

stream = nghttp3_conn_find_stream(conn, stream_id);
if (stream == NULL) {
/* TODO Assert idtr */
Expand Down Expand Up @@ -434,6 +424,10 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
return rv;
}
}
} else if (!nghttp3_client_stream_uni(stream_id)) {
/* server does not expect to receive new server initiated
bidirectional or unidirectional stream from client. */
return NGHTTP3_ERR_H3_STREAM_CREATION_ERROR;
} else {
/* unidirectional stream */
if (srclen == 0 && fin) {
Expand All @@ -448,7 +442,7 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,

stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
stream->tx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
} else if (nghttp3_stream_uni(stream_id)) {
} else if (nghttp3_server_stream_uni(stream_id)) {
if (srclen == 0 && fin) {
return 0;
}
Expand All @@ -461,8 +455,8 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
stream->rx.hstate = NGHTTP3_HTTP_STATE_RESP_INITIAL;
stream->tx.hstate = NGHTTP3_HTTP_STATE_RESP_INITIAL;
} else {
/* client doesn't expect to receive new bidirectional stream
from server. */
/* client doesn't expect to receive new bidirectional stream or
client initiated unidirectional stream from server. */
return NGHTTP3_ERR_H3_STREAM_CREATION_ERROR;
}
} else if (conn->server) {
Expand All @@ -471,7 +465,12 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
stream->tx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
}
} else {
assert(nghttp3_client_stream_uni(stream_id));
}
} else {
assert(nghttp3_client_stream_bidi(stream_id) ||
nghttp3_server_stream_uni(stream_id));
}

if (srclen == 0 && !fin) {
Expand Down Expand Up @@ -608,6 +607,9 @@ nghttp3_ssize nghttp3_conn_read_uni(nghttp3_conn *conn, nghttp3_stream *stream,
break;
case NGHTTP3_STREAM_TYPE_UNKNOWN:
nconsumed = (nghttp3_ssize)srclen;
if (fin) {
break;
}

rv = conn_call_stop_sending(conn, stream, NGHTTP3_H3_STREAM_CREATION_ERROR);
if (rv != 0) {
Expand Down Expand Up @@ -1836,7 +1838,7 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream,
nghttp3_stream *stream;
int rv;
nghttp3_stream_callbacks callbacks = {
conn_stream_acked_data,
.acked_data = conn_stream_acked_data,
};

rv = nghttp3_stream_new(&stream, stream_id, &callbacks,
Expand Down Expand Up @@ -1874,6 +1876,8 @@ int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) {
nghttp3_frame_entry frent;
int rv;

assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
assert(!conn->server || nghttp3_server_stream_uni(stream_id));
assert(conn->server || nghttp3_client_stream_uni(stream_id));

Expand Down Expand Up @@ -1906,6 +1910,10 @@ int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn, int64_t qenc_stream_id,
nghttp3_stream *stream;
int rv;

assert(qenc_stream_id >= 0);
assert(qenc_stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
assert(qdec_stream_id >= 0);
assert(qdec_stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
assert(!conn->server || nghttp3_server_stream_uni(qenc_stream_id));
assert(!conn->server || nghttp3_server_stream_uni(qdec_stream_id));
assert(conn->server || nghttp3_client_stream_uni(qenc_stream_id));
Expand Down Expand Up @@ -2194,13 +2202,11 @@ int nghttp3_conn_submit_request(nghttp3_conn *conn, int64_t stream_id,
assert(!conn->server);
assert(conn->tx.qenc);

assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
assert(nghttp3_client_stream_bidi(stream_id));

/* TODO Should we check that stream_id is client stream_id? */
/* TODO Check GOAWAY last stream ID */
if (nghttp3_stream_uni(stream_id)) {
return NGHTTP3_ERR_INVALID_ARGUMENT;
}

if (conn->flags & NGHTTP3_CONN_FLAG_GOAWAY_RECVED) {
return NGHTTP3_ERR_CONN_CLOSING;
Expand Down Expand Up @@ -2454,6 +2460,9 @@ int nghttp3_conn_close_stream(nghttp3_conn *conn, int64_t stream_id,
int nghttp3_conn_shutdown_stream_read(nghttp3_conn *conn, int64_t stream_id) {
nghttp3_stream *stream;

assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);

if (!nghttp3_client_stream_bidi(stream_id)) {
return 0;
}
Expand Down Expand Up @@ -2515,6 +2524,9 @@ uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn,
nghttp3_stream *stream;
int uni = 0;

assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);

if (!nghttp3_client_stream_bidi(stream_id)) {
uni = conn_remote_stream_uni(conn, stream_id);
if (!uni) {
Expand Down Expand Up @@ -2542,6 +2554,8 @@ int nghttp3_conn_get_stream_priority_versioned(nghttp3_conn *conn,
(void)pri_version;

assert(conn->server);
assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);

if (!nghttp3_client_stream_bidi(stream_id)) {
return NGHTTP3_ERR_INVALID_ARGUMENT;
Expand All @@ -2566,6 +2580,8 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn,
uint8_t *buf = NULL;

assert(!conn->server);
assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);

if (!nghttp3_client_stream_bidi(stream_id)) {
return NGHTTP3_ERR_INVALID_ARGUMENT;
Expand Down Expand Up @@ -2603,6 +2619,8 @@ int nghttp3_conn_set_server_stream_priority_versioned(nghttp3_conn *conn,
assert(conn->server);
assert(pri->urgency < NGHTTP3_URGENCY_LEVELS);
assert(pri->inc == 0 || pri->inc == 1);
assert(stream_id >= 0);
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);

if (!nghttp3_client_stream_bidi(stream_id)) {
return NGHTTP3_ERR_INVALID_ARGUMENT;
Expand Down
2 changes: 1 addition & 1 deletion deps/ngtcp2/nghttp3/lib/nghttp3_conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct nghttp3_chunk {
nghttp3_opl_entry oplent;
} nghttp3_chunk;

nghttp3_objalloc_decl(chunk, nghttp3_chunk, oplent);
nghttp3_objalloc_decl(chunk, nghttp3_chunk, oplent)

struct nghttp3_conn {
nghttp3_objalloc out_chunk_objalloc;
Expand Down
39 changes: 27 additions & 12 deletions deps/ngtcp2/nghttp3/lib/nghttp3_gaptr.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@
#include <assert.h>

void nghttp3_gaptr_init(nghttp3_gaptr *gaptr, const nghttp3_mem *mem) {
nghttp3_ksl_init(&gaptr->gap, nghttp3_ksl_range_compar, sizeof(nghttp3_range),
mem);
nghttp3_ksl_init(&gaptr->gap, nghttp3_ksl_range_compar,
nghttp3_ksl_range_search, sizeof(nghttp3_range), mem);

gaptr->mem = mem;
}

static int gaptr_gap_init(nghttp3_gaptr *gaptr) {
nghttp3_range range = {0, UINT64_MAX};
nghttp3_range range = {
.end = UINT64_MAX,
};

return nghttp3_ksl_insert(&gaptr->gap, NULL, &range, NULL);
}
Expand All @@ -52,7 +54,11 @@ void nghttp3_gaptr_free(nghttp3_gaptr *gaptr) {
int nghttp3_gaptr_push(nghttp3_gaptr *gaptr, uint64_t offset,
uint64_t datalen) {
int rv;
nghttp3_range k, m, l, r, q = {offset, offset + datalen};
nghttp3_range k, m, l, r;
nghttp3_range q = {
.begin = offset,
.end = offset + datalen,
};
nghttp3_ksl_it it;

if (nghttp3_ksl_len(&gaptr->gap) == 0) {
Expand All @@ -62,8 +68,8 @@ int nghttp3_gaptr_push(nghttp3_gaptr *gaptr, uint64_t offset,
}
}

it = nghttp3_ksl_lower_bound_compar(&gaptr->gap, &q,
nghttp3_ksl_range_exclusive_compar);
it = nghttp3_ksl_lower_bound_search(&gaptr->gap, &q,
nghttp3_ksl_range_exclusive_search);

for (; !nghttp3_ksl_it_end(&it);) {
k = *(nghttp3_range *)nghttp3_ksl_it_key(&it);
Expand Down Expand Up @@ -112,16 +118,19 @@ uint64_t nghttp3_gaptr_first_gap_offset(nghttp3_gaptr *gaptr) {

nghttp3_range nghttp3_gaptr_get_first_gap_after(nghttp3_gaptr *gaptr,
uint64_t offset) {
nghttp3_range q = {offset, offset + 1};
nghttp3_range q = {
.begin = offset,
.end = offset + 1,
};
nghttp3_ksl_it it;

if (nghttp3_ksl_len(&gaptr->gap) == 0) {
nghttp3_range r = {0, UINT64_MAX};
return r;
}

it = nghttp3_ksl_lower_bound_compar(&gaptr->gap, &q,
nghttp3_ksl_range_exclusive_compar);
it = nghttp3_ksl_lower_bound_search(&gaptr->gap, &q,
nghttp3_ksl_range_exclusive_search);

assert(!nghttp3_ksl_it_end(&it));

Expand All @@ -130,16 +139,22 @@ nghttp3_range nghttp3_gaptr_get_first_gap_after(nghttp3_gaptr *gaptr,

int nghttp3_gaptr_is_pushed(nghttp3_gaptr *gaptr, uint64_t offset,
uint64_t datalen) {
nghttp3_range q = {offset, offset + datalen};
nghttp3_range q = {
.begin = offset,
.end = offset + datalen,
};
nghttp3_ksl_it it;
nghttp3_range m;

if (nghttp3_ksl_len(&gaptr->gap) == 0) {
return 0;
}

it = nghttp3_ksl_lower_bound_compar(&gaptr->gap, &q,
nghttp3_ksl_range_exclusive_compar);
it = nghttp3_ksl_lower_bound_search(&gaptr->gap, &q,
nghttp3_ksl_range_exclusive_search);

assert(!nghttp3_ksl_it_end(&it));

m = nghttp3_range_intersect(&q, (nghttp3_range *)nghttp3_ksl_it_key(&it));

return nghttp3_range_len(&m) == 0;
Expand Down
Loading
Loading