Skip to content

Commit 458199b

Browse files
deps: update nghttp3 to 1.9.0
1 parent 4edb139 commit 458199b

26 files changed

+1131
-744
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.9.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 0x010900
4545

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

deps/ngtcp2/nghttp3/lib/nghttp3_buf.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ size_t nghttp3_buf_cap(const nghttp3_buf *buf) {
5050
return (size_t)(buf->end - buf->begin);
5151
}
5252

53+
size_t nghttp3_buf_offset(const nghttp3_buf *buf) {
54+
return (size_t)(buf->pos - buf->begin);
55+
}
56+
5357
void nghttp3_buf_reset(nghttp3_buf *buf) { buf->pos = buf->last = buf->begin; }
5458

5559
int nghttp3_buf_reserve(nghttp3_buf *buf, size_t size, const nghttp3_mem *mem) {
@@ -87,4 +91,12 @@ void nghttp3_typed_buf_init(nghttp3_typed_buf *tbuf, const nghttp3_buf *buf,
8791
nghttp3_buf_type type) {
8892
tbuf->buf = *buf;
8993
tbuf->type = type;
94+
tbuf->buf.begin = tbuf->buf.pos;
95+
}
96+
97+
void nghttp3_typed_buf_shared_init(nghttp3_typed_buf *tbuf,
98+
const nghttp3_buf *chunk) {
99+
tbuf->buf = *chunk;
100+
tbuf->type = NGHTTP3_BUF_TYPE_SHARED;
101+
tbuf->buf.begin = tbuf->buf.pos = tbuf->buf.last;
90102
}

deps/ngtcp2/nghttp3/lib/nghttp3_buf.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ void nghttp3_buf_wrap_init(nghttp3_buf *buf, uint8_t *src, size_t len);
4242
*/
4343
size_t nghttp3_buf_cap(const nghttp3_buf *buf);
4444

45+
/*
46+
* nghttp3_buf_offset returns the distance from tbuf->begin to
47+
* tbuf->pos. In other words, it returns buf->pos - buf->begin.
48+
*/
49+
size_t nghttp3_buf_offset(const nghttp3_buf *buf);
50+
4551
int nghttp3_buf_reserve(nghttp3_buf *buf, size_t size, const nghttp3_mem *mem);
4652

4753
/*
@@ -69,6 +75,13 @@ typedef struct nghttp3_typed_buf {
6975
void nghttp3_typed_buf_init(nghttp3_typed_buf *tbuf, const nghttp3_buf *buf,
7076
nghttp3_buf_type type);
7177

78+
/*
79+
* nghttp3_typed_buf_shared_init initializes |tbuf| of type
80+
* NGHTTP3_BUF_TYPE_SHARED.
81+
*/
82+
void nghttp3_typed_buf_shared_init(nghttp3_typed_buf *tbuf,
83+
const nghttp3_buf *chunk);
84+
7285
void nghttp3_typed_buf_free(nghttp3_typed_buf *tbuf);
7386

7487
#endif /* !defined(NGHTTP3_BUF_H) */

deps/ngtcp2/nghttp3/lib/nghttp3_conn.c

Lines changed: 51 additions & 37 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,17 +455,16 @@ 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) {
469-
if (nghttp3_client_stream_bidi(stream_id)) {
470-
if (stream->rx.hstate == NGHTTP3_HTTP_STATE_NONE) {
471-
stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
472-
stream->tx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
473-
}
474-
}
463+
assert(nghttp3_client_stream_bidi(stream_id) ||
464+
nghttp3_client_stream_uni(stream_id));
465+
} else {
466+
assert(nghttp3_client_stream_bidi(stream_id) ||
467+
nghttp3_server_stream_uni(stream_id));
475468
}
476469

477470
if (srclen == 0 && !fin) {
@@ -608,6 +601,9 @@ nghttp3_ssize nghttp3_conn_read_uni(nghttp3_conn *conn, nghttp3_stream *stream,
608601
break;
609602
case NGHTTP3_STREAM_TYPE_UNKNOWN:
610603
nconsumed = (nghttp3_ssize)srclen;
604+
if (fin) {
605+
break;
606+
}
611607

612608
rv = conn_call_stop_sending(conn, stream, NGHTTP3_H3_STREAM_CREATION_ERROR);
613609
if (rv != 0) {
@@ -1792,6 +1788,8 @@ conn_on_priority_update_stream(nghttp3_conn *conn,
17921788

17931789
stream->node.pri = fr->pri;
17941790
stream->flags |= NGHTTP3_STREAM_FLAG_PRIORITY_UPDATE_RECVED;
1791+
stream->rx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
1792+
stream->tx.hstate = NGHTTP3_HTTP_STATE_REQ_INITIAL;
17951793

17961794
return 0;
17971795
}
@@ -1836,7 +1834,7 @@ int nghttp3_conn_create_stream(nghttp3_conn *conn, nghttp3_stream **pstream,
18361834
nghttp3_stream *stream;
18371835
int rv;
18381836
nghttp3_stream_callbacks callbacks = {
1839-
conn_stream_acked_data,
1837+
.acked_data = conn_stream_acked_data,
18401838
};
18411839

18421840
rv = nghttp3_stream_new(&stream, stream_id, &callbacks,
@@ -1874,6 +1872,8 @@ int nghttp3_conn_bind_control_stream(nghttp3_conn *conn, int64_t stream_id) {
18741872
nghttp3_frame_entry frent;
18751873
int rv;
18761874

1875+
assert(stream_id >= 0);
1876+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
18771877
assert(!conn->server || nghttp3_server_stream_uni(stream_id));
18781878
assert(conn->server || nghttp3_client_stream_uni(stream_id));
18791879

@@ -1906,6 +1906,10 @@ int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn, int64_t qenc_stream_id,
19061906
nghttp3_stream *stream;
19071907
int rv;
19081908

1909+
assert(qenc_stream_id >= 0);
1910+
assert(qenc_stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
1911+
assert(qdec_stream_id >= 0);
1912+
assert(qdec_stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
19091913
assert(!conn->server || nghttp3_server_stream_uni(qenc_stream_id));
19101914
assert(!conn->server || nghttp3_server_stream_uni(qdec_stream_id));
19111915
assert(conn->server || nghttp3_client_stream_uni(qenc_stream_id));
@@ -2194,13 +2198,11 @@ int nghttp3_conn_submit_request(nghttp3_conn *conn, int64_t stream_id,
21942198
assert(!conn->server);
21952199
assert(conn->tx.qenc);
21962200

2201+
assert(stream_id >= 0);
2202+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
21972203
assert(nghttp3_client_stream_bidi(stream_id));
21982204

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

22052207
if (conn->flags & NGHTTP3_CONN_FLAG_GOAWAY_RECVED) {
22062208
return NGHTTP3_ERR_CONN_CLOSING;
@@ -2454,6 +2456,9 @@ int nghttp3_conn_close_stream(nghttp3_conn *conn, int64_t stream_id,
24542456
int nghttp3_conn_shutdown_stream_read(nghttp3_conn *conn, int64_t stream_id) {
24552457
nghttp3_stream *stream;
24562458

2459+
assert(stream_id >= 0);
2460+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
2461+
24572462
if (!nghttp3_client_stream_bidi(stream_id)) {
24582463
return 0;
24592464
}
@@ -2515,6 +2520,9 @@ uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn,
25152520
nghttp3_stream *stream;
25162521
int uni = 0;
25172522

2523+
assert(stream_id >= 0);
2524+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
2525+
25182526
if (!nghttp3_client_stream_bidi(stream_id)) {
25192527
uni = conn_remote_stream_uni(conn, stream_id);
25202528
if (!uni) {
@@ -2542,6 +2550,8 @@ int nghttp3_conn_get_stream_priority_versioned(nghttp3_conn *conn,
25422550
(void)pri_version;
25432551

25442552
assert(conn->server);
2553+
assert(stream_id >= 0);
2554+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
25452555

25462556
if (!nghttp3_client_stream_bidi(stream_id)) {
25472557
return NGHTTP3_ERR_INVALID_ARGUMENT;
@@ -2566,6 +2576,8 @@ int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn,
25662576
uint8_t *buf = NULL;
25672577

25682578
assert(!conn->server);
2579+
assert(stream_id >= 0);
2580+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
25692581

25702582
if (!nghttp3_client_stream_bidi(stream_id)) {
25712583
return NGHTTP3_ERR_INVALID_ARGUMENT;
@@ -2603,6 +2615,8 @@ int nghttp3_conn_set_server_stream_priority_versioned(nghttp3_conn *conn,
26032615
assert(conn->server);
26042616
assert(pri->urgency < NGHTTP3_URGENCY_LEVELS);
26052617
assert(pri->inc == 0 || pri->inc == 1);
2618+
assert(stream_id >= 0);
2619+
assert(stream_id <= (int64_t)NGHTTP3_MAX_VARINT);
26062620

26072621
if (!nghttp3_client_stream_bidi(stream_id)) {
26082622
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_conv.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p) {
6666
}
6767
}
6868

69-
int64_t nghttp3_get_varint_fb(const uint8_t *p) { return *p & 0x3f; }
70-
7169
size_t nghttp3_get_varintlen(const uint8_t *p) {
7270
return (size_t)(1u << (*p >> 6));
7371
}

deps/ngtcp2/nghttp3/lib/nghttp3_conv.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,6 @@ STIN uint16_t ntohs(uint16_t netshort) {
135135
*/
136136
const uint8_t *nghttp3_get_varint(int64_t *dest, const uint8_t *p);
137137

138-
/*
139-
* nghttp3_get_varint_fb reads first byte of encoded variable-length
140-
* integer from |p|.
141-
*/
142-
int64_t nghttp3_get_varint_fb(const uint8_t *p);
143-
144138
/*
145139
* nghttp3_get_varintlen returns the required number of bytes to read
146140
* variable-length integer starting at |p|.

0 commit comments

Comments
 (0)