Skip to content

Commit 8ccb4a3

Browse files
deps: update nghttp3 to 1.8.0
1 parent 09ecd2e commit 8ccb4a3

20 files changed

+1020
-582
lines changed

deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
21062106
* control credit (both stream and connection) of underlying QUIC
21072107
* connection by that amount. It does not include the amount of data
21082108
* carried by DATA frame which contains application data (excluding
2109-
* any control or QPACK unidirectional streams) . See
2109+
* any control or QPACK unidirectional streams). See
21102110
* :type:`nghttp3_recv_data` to handle those bytes. If |fin| is
21112111
* nonzero, this is the last data from remote endpoint in this stream.
21122112
*
@@ -2480,8 +2480,6 @@ typedef struct nghttp3_data_reader {
24802480
* This function returns 0 if it succeeds, or one of the following
24812481
* negative error codes:
24822482
*
2483-
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2484-
* |stream_id| identifies unidirectional stream.
24852483
* :macro:`NGHTTP3_ERR_CONN_CLOSING`
24862484
* Connection is shutting down, and no new stream is allowed.
24872485
* :macro:`NGHTTP3_ERR_STREAM_IN_USE`

deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* Version number of the nghttp3 library release.
3333
*/
34-
#define NGHTTP3_VERSION "1.6.0"
34+
#define NGHTTP3_VERSION "1.8.0"
3535

3636
/**
3737
* @macro
@@ -41,6 +41,6 @@
4141
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
4242
* becomes 0x010203.
4343
*/
44-
#define NGHTTP3_VERSION_NUM 0x010600
44+
#define NGHTTP3_VERSION_NUM 0x010800
4545

4646
#endif /* !defined(NGHTTP3_VERSION_H) */

deps/ngtcp2/nghttp3/lib/nghttp3_conn.c

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
dynamic table capacity that QPACK encoder is willing to use. */
4040
#define NGHTTP3_QPACK_ENCODER_MAX_DTABLE_CAPACITY 4096
4141

42-
nghttp3_objalloc_def(chunk, nghttp3_chunk, oplent);
42+
nghttp3_objalloc_def(chunk, nghttp3_chunk, oplent)
4343

4444
/*
4545
* conn_remote_stream_uni returns nonzero if |stream_id| is remote
@@ -233,12 +233,16 @@ static int conn_new(nghttp3_conn **pconn, int server, int callbacks_version,
233233
const nghttp3_callbacks *callbacks, int settings_version,
234234
const nghttp3_settings *settings, const nghttp3_mem *mem,
235235
void *user_data) {
236-
int rv;
237236
nghttp3_conn *conn;
238237
size_t i;
239238
(void)callbacks_version;
240239
(void)settings_version;
241240

241+
assert(settings->max_field_section_size <= NGHTTP3_VARINT_MAX);
242+
assert(settings->qpack_max_dtable_capacity <= NGHTTP3_VARINT_MAX);
243+
assert(settings->qpack_encoder_max_dtable_capacity <= NGHTTP3_VARINT_MAX);
244+
assert(settings->qpack_blocked_streams <= NGHTTP3_VARINT_MAX);
245+
242246
if (mem == NULL) {
243247
mem = nghttp3_mem_default();
244248
}
@@ -254,18 +258,11 @@ static int conn_new(nghttp3_conn **pconn, int server, int callbacks_version,
254258

255259
nghttp3_map_init(&conn->streams, mem);
256260

257-
rv =
258-
nghttp3_qpack_decoder_init(&conn->qdec, settings->qpack_max_dtable_capacity,
259-
settings->qpack_blocked_streams, mem);
260-
if (rv != 0) {
261-
goto qdec_init_fail;
262-
}
261+
nghttp3_qpack_decoder_init(&conn->qdec, settings->qpack_max_dtable_capacity,
262+
settings->qpack_blocked_streams, mem);
263263

264-
rv = nghttp3_qpack_encoder_init(
265-
&conn->qenc, settings->qpack_encoder_max_dtable_capacity, mem);
266-
if (rv != 0) {
267-
goto qenc_init_fail;
268-
}
264+
nghttp3_qpack_encoder_init(&conn->qenc,
265+
settings->qpack_encoder_max_dtable_capacity, mem);
269266

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

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

293290
return 0;
294-
295-
qenc_init_fail:
296-
nghttp3_qpack_decoder_free(&conn->qdec);
297-
qdec_init_fail:
298-
nghttp3_map_free(&conn->streams);
299-
nghttp3_objalloc_free(&conn->stream_objalloc);
300-
nghttp3_objalloc_free(&conn->out_chunk_objalloc);
301-
nghttp3_mem_free(mem, conn);
302-
303-
return rv;
304291
}
305292

306293
int nghttp3_conn_client_new_versioned(nghttp3_conn **pconn,
@@ -399,6 +386,9 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
399386
size_t bidi_nproc;
400387
int rv;
401388

389+
assert(stream_id >= 0);
390+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
391+
402392
stream = nghttp3_conn_find_stream(conn, stream_id);
403393
if (stream == NULL) {
404394
/* TODO Assert idtr */
@@ -434,6 +424,10 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
434424
return rv;
435425
}
436426
}
427+
} else if (!nghttp3_client_stream_uni(stream_id)) {
428+
/* server does not expect to receive new server initiated
429+
bidirectional or unidirectional stream from client. */
430+
return NGHTTP3_ERR_H3_STREAM_CREATION_ERROR;
437431
} else {
438432
/* unidirectional stream */
439433
if (srclen == 0 && fin) {
@@ -448,7 +442,7 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
448442

449443
stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
450444
stream->tx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
451-
} else if (nghttp3_stream_uni(stream_id)) {
445+
} else if (nghttp3_server_stream_uni(stream_id)) {
452446
if (srclen == 0 && fin) {
453447
return 0;
454448
}
@@ -461,8 +455,8 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
461455
stream->rx.hstate = NGHTTP3_HTTP_STATE_RESP_INITIAL;
462456
stream->tx.hstate = NGHTTP3_HTTP_STATE_RESP_INITIAL;
463457
} else {
464-
/* client doesn't expect to receive new bidirectional stream
465-
from server. */
458+
/* client doesn't expect to receive new bidirectional stream or
459+
client initiated unidirectional stream from server. */
466460
return NGHTTP3_ERR_H3_STREAM_CREATION_ERROR;
467461
}
468462
} else if (conn->server) {
@@ -471,7 +465,12 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
471465
stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
472466
stream->tx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
473467
}
468+
} else {
469+
assert(nghttp3_client_stream_uni(stream_id));
474470
}
471+
} else {
472+
assert(nghttp3_client_stream_bidi(stream_id) ||
473+
nghttp3_server_stream_uni(stream_id));
475474
}
476475

477476
if (srclen == 0 && !fin) {
@@ -608,6 +607,9 @@ nghttp3_ssize nghttp3_conn_read_uni(nghttp3_conn *conn, nghttp3_stream *stream,
608607
break;
609608
case NGHTTP3_STREAM_TYPE_UNKNOWN:
610609
nconsumed = (nghttp3_ssize)srclen;
610+
if (fin) {
611+
break;
612+
}
611613

612614
rv = conn_call_stop_sending(conn, stream, NGHTTP3_H3_STREAM_CREATION_ERROR);
613615
if (rv != 0) {
@@ -1836,7 +1838,7 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream,
18361838
nghttp3_stream *stream;
18371839
int rv;
18381840
nghttp3_stream_callbacks callbacks = {
1839-
conn_stream_acked_data,
1841+
.acked_data = conn_stream_acked_data,
18401842
};
18411843

18421844
rv = nghttp3_stream_new(&stream, stream_id, &callbacks,
@@ -1874,6 +1876,8 @@ int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) {
18741876
nghttp3_frame_entry frent;
18751877
int rv;
18761878

1879+
assert(stream_id >= 0);
1880+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
18771881
assert(!conn->server || nghttp3_server_stream_uni(stream_id));
18781882
assert(conn->server || nghttp3_client_stream_uni(stream_id));
18791883

@@ -1906,6 +1910,10 @@ int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn, int64_t qenc_stream_id,
19061910
nghttp3_stream *stream;
19071911
int rv;
19081912

1913+
assert(qenc_stream_id >= 0);
1914+
assert(qenc_stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
1915+
assert(qdec_stream_id >= 0);
1916+
assert(qdec_stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
19091917
assert(!conn->server || nghttp3_server_stream_uni(qenc_stream_id));
19101918
assert(!conn->server || nghttp3_server_stream_uni(qdec_stream_id));
19111919
assert(conn->server || nghttp3_client_stream_uni(qenc_stream_id));
@@ -2194,13 +2202,11 @@ int nghttp3_conn_submit_request(nghttp3_conn *conn, int64_t stream_id,
21942202
assert(!conn->server);
21952203
assert(conn->tx.qenc);
21962204

2205+
assert(stream_id >= 0);
2206+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
21972207
assert(nghttp3_client_stream_bidi(stream_id));
21982208

2199-
/* TODO Should we check that stream_id is client stream_id? */
22002209
/* TODO Check GOAWAY last stream ID */
2201-
if (nghttp3_stream_uni(stream_id)) {
2202-
return NGHTTP3_ERR_INVALID_ARGUMENT;
2203-
}
22042210

22052211
if (conn->flags & NGHTTP3_CONN_FLAG_GOAWAY_RECVED) {
22062212
return NGHTTP3_ERR_CONN_CLOSING;
@@ -2454,6 +2460,9 @@ int nghttp3_conn_close_stream(nghttp3_conn *conn, int64_t stream_id,
24542460
int nghttp3_conn_shutdown_stream_read(nghttp3_conn *conn, int64_t stream_id) {
24552461
nghttp3_stream *stream;
24562462

2463+
assert(stream_id >= 0);
2464+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
2465+
24572466
if (!nghttp3_client_stream_bidi(stream_id)) {
24582467
return 0;
24592468
}
@@ -2515,6 +2524,9 @@ uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn,
25152524
nghttp3_stream *stream;
25162525
int uni = 0;
25172526

2527+
assert(stream_id >= 0);
2528+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
2529+
25182530
if (!nghttp3_client_stream_bidi(stream_id)) {
25192531
uni = conn_remote_stream_uni(conn, stream_id);
25202532
if (!uni) {
@@ -2542,6 +2554,8 @@ int nghttp3_conn_get_stream_priority_versioned(nghttp3_conn *conn,
25422554
(void)pri_version;
25432555

25442556
assert(conn->server);
2557+
assert(stream_id >= 0);
2558+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
25452559

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

25682582
assert(!conn->server);
2583+
assert(stream_id >= 0);
2584+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
25692585

25702586
if (!nghttp3_client_stream_bidi(stream_id)) {
25712587
return NGHTTP3_ERR_INVALID_ARGUMENT;
@@ -2603,6 +2619,8 @@ int nghttp3_conn_set_server_stream_priority_versioned(nghttp3_conn *conn,
26032619
assert(conn->server);
26042620
assert(pri->urgency < NGHTTP3_URGENCY_LEVELS);
26052621
assert(pri->inc == 0 || pri->inc == 1);
2622+
assert(stream_id >= 0);
2623+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
26062624

26072625
if (!nghttp3_client_stream_bidi(stream_id)) {
26082626
return NGHTTP3_ERR_INVALID_ARGUMENT;

deps/ngtcp2/nghttp3/lib/nghttp3_conn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ typedef struct nghttp3_chunk {
7676
nghttp3_opl_entry oplent;
7777
} nghttp3_chunk;
7878

79-
nghttp3_objalloc_decl(chunk, nghttp3_chunk, oplent);
79+
nghttp3_objalloc_decl(chunk, nghttp3_chunk, oplent)
8080

8181
struct nghttp3_conn {
8282
nghttp3_objalloc out_chunk_objalloc;

deps/ngtcp2/nghttp3/lib/nghttp3_gaptr.c

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@
2929
#include <assert.h>
3030

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

3535
gaptr->mem = mem;
3636
}
3737

3838
static int gaptr_gap_init(nghttp3_gaptr *gaptr) {
39-
nghttp3_range range = {0, UINT64_MAX};
39+
nghttp3_range range = {
40+
.end = UINT64_MAX,
41+
};
4042

4143
return nghttp3_ksl_insert(&gaptr->gap, NULL, &range, NULL);
4244
}
@@ -52,7 +54,11 @@ void nghttp3_gaptr_free(nghttp3_gaptr *gaptr) {
5254
int nghttp3_gaptr_push(nghttp3_gaptr *gaptr, uint64_t offset,
5355
uint64_t datalen) {
5456
int rv;
55-
nghttp3_range k, m, l, r, q = {offset, offset + datalen};
57+
nghttp3_range k, m, l, r;
58+
nghttp3_range q = {
59+
.begin = offset,
60+
.end = offset + datalen,
61+
};
5662
nghttp3_ksl_it it;
5763

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

65-
it = nghttp3_ksl_lower_bound_compar(&gaptr->gap, &q,
66-
nghttp3_ksl_range_exclusive_compar);
71+
it = nghttp3_ksl_lower_bound_search(&gaptr->gap, &q,
72+
nghttp3_ksl_range_exclusive_search);
6773

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

113119
nghttp3_range nghttp3_gaptr_get_first_gap_after(nghttp3_gaptr *gaptr,
114120
uint64_t offset) {
115-
nghttp3_range q = {offset, offset + 1};
121+
nghttp3_range q = {
122+
.begin = offset,
123+
.end = offset + 1,
124+
};
116125
nghttp3_ksl_it it;
117126

118127
if (nghttp3_ksl_len(&gaptr->gap) == 0) {
119128
nghttp3_range r = {0, UINT64_MAX};
120129
return r;
121130
}
122131

123-
it = nghttp3_ksl_lower_bound_compar(&gaptr->gap, &q,
124-
nghttp3_ksl_range_exclusive_compar);
132+
it = nghttp3_ksl_lower_bound_search(&gaptr->gap, &q,
133+
nghttp3_ksl_range_exclusive_search);
125134

126135
assert(!nghttp3_ksl_it_end(&it));
127136

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

131140
int nghttp3_gaptr_is_pushed(nghttp3_gaptr *gaptr, uint64_t offset,
132141
uint64_t datalen) {
133-
nghttp3_range q = {offset, offset + datalen};
142+
nghttp3_range q = {
143+
.begin = offset,
144+
.end = offset + datalen,
145+
};
134146
nghttp3_ksl_it it;
135147
nghttp3_range m;
136148

137149
if (nghttp3_ksl_len(&gaptr->gap) == 0) {
138150
return 0;
139151
}
140152

141-
it = nghttp3_ksl_lower_bound_compar(&gaptr->gap, &q,
142-
nghttp3_ksl_range_exclusive_compar);
153+
it = nghttp3_ksl_lower_bound_search(&gaptr->gap, &q,
154+
nghttp3_ksl_range_exclusive_search);
155+
156+
assert(!nghttp3_ksl_it_end(&it));
157+
143158
m = nghttp3_range_intersect(&q, (nghttp3_range *)nghttp3_ksl_it_key(&it));
144159

145160
return nghttp3_range_len(&m) == 0;

0 commit comments

Comments
 (0)