Skip to content

Commit ebbb978

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update nghttp3 to 1.18.0
PR-URL: #64943 Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent a7625d5 commit ebbb978

10 files changed

Lines changed: 227 additions & 51 deletions

File tree

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

Lines changed: 125 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,7 +1961,7 @@ typedef int (*nghttp3_acked_stream_data)(nghttp3_conn *conn, int64_t stream_id,
19611961
/**
19621962
* @functypedef
19631963
*
1964-
* :type:`nghttp3_conn_stream_close` is a callback function which is
1964+
* :type:`nghttp3_stream_close` is a callback function which is
19651965
* invoked when a stream identified by |stream_id| is closed. QUIC
19661966
* application error code |app_error_code| indicates the reason of
19671967
* this closure.
@@ -1970,6 +1970,9 @@ typedef int (*nghttp3_acked_stream_data)(nghttp3_conn *conn, int64_t stream_id,
19701970
* Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
19711971
* caller immediately. Any values other than 0 is treated as
19721972
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1973+
*
1974+
* .. seealso::
1975+
* :type:`nghttp3_stream_close2`
19731976
*/
19741977
typedef int (*nghttp3_stream_close)(nghttp3_conn *conn, int64_t stream_id,
19751978
uint64_t app_error_code,
@@ -2240,10 +2243,80 @@ typedef int (*nghttp3_recv_settings2)(nghttp3_conn *conn,
22402243
const nghttp3_proto_settings *settings,
22412244
void *conn_user_data);
22422245

2246+
/**
2247+
* @macrosection
2248+
*
2249+
* Stream close flags
2250+
*/
2251+
2252+
/**
2253+
* @macro
2254+
*
2255+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_NONE` indicates no flag set.
2256+
*
2257+
* .. version-added:: 1.18.0
2258+
*/
2259+
#define NGHTTP3_STREAM_CLOSE_FLAG_NONE 0x00U
2260+
2261+
/**
2262+
* @macro
2263+
*
2264+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` indicates
2265+
* that rx_app_error_code parameter is set.
2266+
*
2267+
* .. version-added:: 1.18.0
2268+
*/
2269+
#define NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET 0x01U
2270+
2271+
/**
2272+
* @macro
2273+
*
2274+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` indicates
2275+
* that tx_app_error_code parameter is set.
2276+
*
2277+
* .. version-added:: 1.18.0
2278+
*/
2279+
#define NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET 0x02U
2280+
2281+
/**
2282+
* @functypedef
2283+
*
2284+
* :type:`nghttp3_stream_close2` is a callback function which is
2285+
* invoked when a stream identified by |stream_id| is closed. If
2286+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` is set in
2287+
* |flags|, |rx_app_error_code| is the QUIC application error code
2288+
* that shut down the receiving side of the stream. If
2289+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` is set in
2290+
* |flags|, |tx_app_error_code| is the QUIC application error code
2291+
* that shut down the sending side of the stream. No application code
2292+
* means that direction of stream is closed without any error.
2293+
*
2294+
* This callback should be used with `nghttp3_conn_close_stream2`. If
2295+
* `nghttp3_conn_close_stream` is used, the app_error_code is set to
2296+
* both |rx_app_error_code| and |tx_app_error_code|, and
2297+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` and
2298+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` are set in
2299+
* |flags|.
2300+
*
2301+
* The implementation of this callback must return 0 if it succeeds.
2302+
* Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2303+
* caller immediately. Any values other than 0 is treated as
2304+
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2305+
*
2306+
* .. version-added:: 1.18.0
2307+
*/
2308+
typedef int (*nghttp3_stream_close2)(nghttp3_conn *conn, uint32_t flags,
2309+
int64_t stream_id,
2310+
uint64_t rx_app_error_code,
2311+
uint64_t tx_app_error_code,
2312+
void *conn_user_data,
2313+
void *stream_user_data);
2314+
22432315
#define NGHTTP3_CALLBACKS_V1 1
22442316
#define NGHTTP3_CALLBACKS_V2 2
22452317
#define NGHTTP3_CALLBACKS_V3 3
2246-
#define NGHTTP3_CALLBACKS_VERSION NGHTTP3_CALLBACKS_V3
2318+
#define NGHTTP3_CALLBACKS_V4 4
2319+
#define NGHTTP3_CALLBACKS_VERSION NGHTTP3_CALLBACKS_V4
22472320

22482321
/**
22492322
* @struct
@@ -2260,6 +2333,9 @@ typedef struct nghttp3_callbacks {
22602333
/**
22612334
* :member:`stream_close` is a callback function which is invoked
22622335
* when a particular stream has closed.
2336+
*
2337+
* .. seealso::
2338+
* :member:`stream_close2`
22632339
*/
22642340
nghttp3_stream_close stream_close;
22652341
/**
@@ -2368,13 +2444,24 @@ typedef struct nghttp3_callbacks {
23682444
* .. version-added:: 1.11.0
23692445
*/
23702446
nghttp3_rand rand;
2447+
/* The following fields have been added since
2448+
NGHTTP3_CALLBACKS_V3. */
23712449
/**
23722450
* :member:`recv_settings2` is a callback function which is invoked
23732451
* when SETTINGS frame is received.
23742452
*
23752453
* .. version-added:: 1.14.0
23762454
*/
23772455
nghttp3_recv_settings2 recv_settings2;
2456+
/* The following fields have been added since
2457+
NGHTTP3_CALLBACKS_V4. */
2458+
/**
2459+
* :member:`stream_close2` is a callback function which is invoked
2460+
* when a particular stream has closed.
2461+
*
2462+
* .. version-added:: 1.18.0
2463+
*/
2464+
nghttp3_stream_close2 stream_close2;
23782465
} nghttp3_callbacks;
23792466

23802467
/**
@@ -2837,11 +2924,47 @@ NGHTTP3_EXTERN int nghttp3_conn_resume_stream(nghttp3_conn *conn,
28372924
* A critical stream is closed.
28382925
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
28392926
* User callback failed
2927+
*
2928+
* .. seealso::
2929+
* `nghttp3_conn_close_stream2`
28402930
*/
28412931
NGHTTP3_EXTERN int nghttp3_conn_close_stream(nghttp3_conn *conn,
28422932
int64_t stream_id,
28432933
uint64_t app_error_code);
28442934

2935+
/**
2936+
* @function
2937+
*
2938+
* `nghttp3_conn_close_stream2` tells the library that a stream
2939+
* identified by |stream_id| has been closed. If
2940+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` is set in
2941+
* |flags|, |rx_app_error_code| is the QUIC application error code
2942+
* that shut down the receiving side of the stream. Similarly,
2943+
* :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` is set in
2944+
* |flags|, |tx_app_error_code| is the QUIC application error code
2945+
* that shut down the sending side of the stream.
2946+
*
2947+
* For stream close callback, prefer
2948+
* :member:`nghttp3_callbacks.stream_close2` to
2949+
* :member:`nghttp3_callbacks.stream_close`.
2950+
*
2951+
* This function returns 0 if it succeeds, or one of the following
2952+
* negative error codes:
2953+
*
2954+
* :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
2955+
* Stream not found.
2956+
* :macro:`NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM`
2957+
* A critical stream is closed.
2958+
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2959+
* User callback failed
2960+
*
2961+
* .. version-added:: 1.18.0
2962+
*/
2963+
NGHTTP3_EXTERN int nghttp3_conn_close_stream2(nghttp3_conn *conn,
2964+
uint32_t flags, int64_t stream_id,
2965+
uint64_t rx_app_error_code,
2966+
uint64_t tx_app_error_code);
2967+
28452968
/**
28462969
* @macrosection
28472970
*

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.17.0"
34+
#define NGHTTP3_VERSION "1.18.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 0x011100
44+
#define NGHTTP3_VERSION_NUM 0x011200
4545

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

deps/ngtcp2/nghttp3/lib/nghttp3_callbacks.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ size_t nghttp3_callbackslen_version(int callbacks_version) {
6666
switch (callbacks_version) {
6767
case NGHTTP3_CALLBACKS_VERSION:
6868
return sizeof(callbacks);
69+
case NGHTTP3_CALLBACKS_V3:
70+
return offsetof(nghttp3_callbacks, recv_settings2) +
71+
sizeof(callbacks.recv_settings2);
6972
case NGHTTP3_CALLBACKS_V2:
7073
return offsetof(nghttp3_callbacks, rand) + sizeof(callbacks.rand);
7174
case NGHTTP3_CALLBACKS_V1:

deps/ngtcp2/nghttp3/lib/nghttp3_conn.c

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,9 @@ static nghttp3_ssize conn_read_type(nghttp3_conn *conn, nghttp3_stream *stream,
623623
return nread;
624624
}
625625

626-
static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream);
626+
static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream,
627+
uint32_t flags, uint64_t rx_app_error_code,
628+
uint64_t tx_app_error_code);
627629

628630
nghttp3_ssize nghttp3_conn_read_uni(nghttp3_conn *conn, nghttp3_stream *stream,
629631
const uint8_t *src, size_t srclen, int fin,
@@ -649,7 +651,8 @@ nghttp3_ssize nghttp3_conn_read_uni(nghttp3_conn *conn, nghttp3_stream *stream,
649651
return NGHTTP3_ERR_H3_EXCESSIVE_LOAD;
650652
}
651653

652-
return conn_delete_stream(conn, stream);
654+
return conn_delete_stream(conn, stream, NGHTTP3_STREAM_CLOSE_FLAG_NONE, 0,
655+
0);
653656
}
654657
nread = conn_read_type(conn, stream, src, srclen, fin);
655658
if (nread < 0) {
@@ -1200,7 +1203,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
12001203
for (; conn->rx.originlen_offset < sizeof(conn->rx.originlen) &&
12011204
(size_t)nread < len;
12021205
++conn->rx.originlen_offset, ++nread) {
1203-
conn->rx.originlen <<= 8;
1206+
conn->rx.originlen *= 256;
12041207
conn->rx.originlen += *p++;
12051208
}
12061209

@@ -1335,8 +1338,11 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
13351338
return (nghttp3_ssize)nconsumed;
13361339
}
13371340

1338-
static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream) {
1341+
static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream,
1342+
uint32_t flags, uint64_t rx_app_error_code,
1343+
uint64_t tx_app_error_code) {
13391344
int rv;
1345+
uint64_t app_error_code;
13401346

13411347
rv = conn_call_deferred_consume(conn, stream,
13421348
nghttp3_stream_get_buffered_datalen(stream));
@@ -1353,8 +1359,26 @@ static int conn_delete_stream(nghttp3_conn *conn, nghttp3_stream *stream) {
13531359
}
13541360
}
13551361

1356-
if (conn->callbacks.stream_close) {
1357-
rv = conn->callbacks.stream_close(conn, stream->node.id, stream->error_code,
1362+
if (conn->callbacks.stream_close2) {
1363+
rv = conn->callbacks.stream_close2(conn, flags, stream->node.id,
1364+
rx_app_error_code, tx_app_error_code,
1365+
conn->user_data, stream->user_data);
1366+
if (rv != 0) {
1367+
return NGHTTP3_ERR_CALLBACK_FAILURE;
1368+
}
1369+
} else if (conn->callbacks.stream_close) {
1370+
app_error_code = NGHTTP3_H3_NO_ERROR;
1371+
1372+
if (flags & NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET) {
1373+
app_error_code = rx_app_error_code;
1374+
}
1375+
1376+
if (app_error_code == NGHTTP3_H3_NO_ERROR &&
1377+
(flags & NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET)) {
1378+
app_error_code = tx_app_error_code;
1379+
}
1380+
1381+
rv = conn->callbacks.stream_close(conn, stream->node.id, app_error_code,
13581382
conn->user_data, stream->user_data);
13591383
if (rv != 0) {
13601384
return NGHTTP3_ERR_CALLBACK_FAILURE;
@@ -2725,6 +2749,16 @@ int nghttp3_conn_resume_stream(nghttp3_conn *conn, int64_t stream_id) {
27252749

27262750
int nghttp3_conn_close_stream(nghttp3_conn *conn, int64_t stream_id,
27272751
uint64_t app_error_code) {
2752+
return nghttp3_conn_close_stream2(
2753+
conn,
2754+
NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET |
2755+
NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET,
2756+
stream_id, app_error_code, app_error_code);
2757+
}
2758+
2759+
int nghttp3_conn_close_stream2(nghttp3_conn *conn, uint32_t flags,
2760+
int64_t stream_id, uint64_t rx_app_error_code,
2761+
uint64_t tx_app_error_code) {
27282762
nghttp3_stream *stream = nghttp3_conn_find_stream(conn, stream_id);
27292763

27302764
if (stream == NULL) {
@@ -2736,11 +2770,10 @@ int nghttp3_conn_close_stream(nghttp3_conn *conn, int64_t stream_id,
27362770
return NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM;
27372771
}
27382772

2739-
stream->error_code = app_error_code;
2740-
27412773
nghttp3_conn_unschedule_stream(conn, stream);
27422774

2743-
return conn_delete_stream(conn, stream);
2775+
return conn_delete_stream(conn, stream, flags, rx_app_error_code,
2776+
tx_app_error_code);
27442777
}
27452778

27462779
int nghttp3_conn_shutdown_stream_read(nghttp3_conn *conn, int64_t stream_id) {

deps/ngtcp2/nghttp3/lib/nghttp3_ksl.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ static nghttp3_ksl_blk null_blk;
3737

3838
nghttp3_objalloc_def(ksl_blk, nghttp3_ksl_blk, oplent)
3939

40+
#define NGHTTP3_KSL_ALIGNED_BLKLEN \
41+
((sizeof(nghttp3_ksl_blk) + 0x7U) & ~(size_t)0x7U)
42+
4043
static size_t ksl_blklen(size_t aligned_keylen) {
41-
return sizeof(nghttp3_ksl_blk) + NGHTTP3_KSL_MAX_NBLK * aligned_keylen;
44+
return NGHTTP3_KSL_ALIGNED_BLKLEN + NGHTTP3_KSL_MAX_NBLK * aligned_keylen;
4245
}
4346

4447
/*
@@ -80,7 +83,7 @@ static nghttp3_ksl_blk *ksl_blk_objalloc_new(nghttp3_ksl *ksl) {
8083
return NULL;
8184
}
8285

83-
blk->keys = (uint8_t *)blk + sizeof(*blk);
86+
blk->keys = (uint8_t *)blk + NGHTTP3_KSL_ALIGNED_BLKLEN;
8487
blk->aligned_keylen = (uint16_t)ksl->aligned_keylen;
8588

8689
return blk;
@@ -223,22 +226,21 @@ static int ksl_split_node(nghttp3_ksl *ksl, nghttp3_ksl_blk *blk, size_t i) {
223226
* Out of memory.
224227
*/
225228
static int ksl_split_root(nghttp3_ksl *ksl) {
226-
nghttp3_ksl_blk *rblk = NULL, *lblk, *nroot = NULL;
229+
nghttp3_ksl_blk *rblk, *lblk, *nroot;
230+
231+
nroot = ksl_blk_objalloc_new(ksl);
232+
if (nroot == NULL) {
233+
return NGHTTP3_ERR_NOMEM;
234+
}
227235

228236
rblk = ksl_split_blk(ksl, ksl->root);
229237
if (rblk == NULL) {
238+
ksl_blk_objalloc_del(ksl, nroot);
230239
return NGHTTP3_ERR_NOMEM;
231240
}
232241

233242
lblk = ksl->root;
234243

235-
nroot = ksl_blk_objalloc_new(ksl);
236-
237-
if (nroot == NULL) {
238-
ksl_blk_objalloc_del(ksl, rblk);
239-
return NGHTTP3_ERR_NOMEM;
240-
}
241-
242244
nroot->next = nroot->prev = NULL;
243245
nroot->n = 2;
244246
nroot->leaf = 0;

0 commit comments

Comments
 (0)