deps: update ngtcp2 to 1.3.0 · nodejs/node@78f84eb · GitHub
Skip to content

Commit 78f84eb

Browse files
nodejs-github-botrichardlau
authored andcommitted
deps: update ngtcp2 to 1.3.0
PR-URL: #51796 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 1f489a3 commit 78f84eb

8 files changed

Lines changed: 205 additions & 93 deletions

File tree

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

Lines changed: 2 additions & 2 deletions

deps/ngtcp2/ngtcp2/lib/ngtcp2_buf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct ngtcp2_buf {
3636
uint8_t *begin;
3737
/* end points to the one beyond of the last byte of the buffer */
3838
uint8_t *end;
39-
/* pos pointers to the start of data. Typically, this points to the
39+
/* pos points to the start of data. Typically, this points to the
4040
point that next data should be read. Initially, it points to
4141
|begin|. */
4242
uint8_t *pos;

deps/ngtcp2/ngtcp2/lib/ngtcp2_cc.c

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
#include <assert.h>
2828
#include <string.h>
2929

30-
#if defined(_MSC_VER)
31-
# include <intrin.h>
32-
#endif
33-
3430
#include "ngtcp2_log.h"
3531
#include "ngtcp2_macro.h"
3632
#include "ngtcp2_mem.h"
@@ -235,39 +231,27 @@ void ngtcp2_cc_cubic_init(ngtcp2_cc_cubic *cubic, ngtcp2_log *log) {
235231
}
236232

237233
uint64_t ngtcp2_cbrt(uint64_t n) {
238-
int d;
239-
uint64_t a;
240-
241-
if (n == 0) {
242-
return 0;
243-
}
244-
245-
#if defined(_MSC_VER)
246-
{
247-
unsigned long index;
248-
# if defined(_WIN64)
249-
if (_BitScanReverse64(&index, n)) {
250-
d = 61 - index;
251-
} else {
252-
ngtcp2_unreachable();
253-
}
254-
# else /* !defined(_WIN64) */
255-
if (_BitScanReverse(&index, (unsigned int)(n >> 32))) {
256-
d = 31 - index;
257-
} else {
258-
d = 32 + 31 - _BitScanReverse(&index, (unsigned int)n);
234+
size_t s;
235+
uint64_t y = 0;
236+
uint64_t b;
237+
238+
for (s = 63; s > 0; s -= 3) {
239+
y <<= 1;
240+
b = 3 * y * (y + 1) + 1;
241+
if ((n >> s) >= b) {
242+
n -= b << s;
243+
y++;
259244
}
260-
# endif /* !defined(_WIN64) */
261245
}
262-
#else /* !defined(_MSC_VER) */
263-
d = __builtin_clzll(n);
264-
#endif /* !defined(_MSC_VER) */
265-
a = 1ULL << ((64 - d) / 3 + 1);
266246

267-
for (; a * a * a > n;) {
268-
a = (2 * a + n / a / a) / 3;
247+
y <<= 1;
248+
b = 3 * y * (y + 1) + 1;
249+
if (n >= b) {
250+
n -= b;
251+
y++;
269252
}
270-
return a;
253+
254+
return y;
271255
}
272256

273257
/* HyStart++ constants */

deps/ngtcp2/ngtcp2/lib/ngtcp2_conn.c

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,12 +3441,22 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
34413441
}
34423442

34433443
switch ((*pfrc)->fr.type) {
3444+
case NGTCP2_FRAME_RESET_STREAM:
3445+
strm =
3446+
ngtcp2_conn_find_stream(conn, (*pfrc)->fr.reset_stream.stream_id);
3447+
if (strm == NULL ||
3448+
!ngtcp2_strm_require_retransmit_reset_stream(strm)) {
3449+
frc = *pfrc;
3450+
*pfrc = (*pfrc)->next;
3451+
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
3452+
continue;
3453+
}
3454+
break;
34443455
case NGTCP2_FRAME_STOP_SENDING:
34453456
strm =
34463457
ngtcp2_conn_find_stream(conn, (*pfrc)->fr.stop_sending.stream_id);
34473458
if (strm == NULL ||
3448-
((strm->flags & NGTCP2_STRM_FLAG_SHUT_RD) &&
3449-
ngtcp2_strm_rx_offset(strm) == strm->rx.last_offset)) {
3459+
!ngtcp2_strm_require_retransmit_stop_sending(strm)) {
34503460
frc = *pfrc;
34513461
*pfrc = (*pfrc)->next;
34523462
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
@@ -3476,10 +3486,8 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
34763486
case NGTCP2_FRAME_MAX_STREAM_DATA:
34773487
strm = ngtcp2_conn_find_stream(conn,
34783488
(*pfrc)->fr.max_stream_data.stream_id);
3479-
if (strm == NULL ||
3480-
(strm->flags &
3481-
(NGTCP2_STRM_FLAG_SHUT_RD | NGTCP2_STRM_FLAG_STOP_SENDING)) ||
3482-
(*pfrc)->fr.max_stream_data.max_stream_data < strm->rx.max_offset) {
3489+
if (strm == NULL || !ngtcp2_strm_require_retransmit_max_stream_data(
3490+
strm, &(*pfrc)->fr.max_stream_data)) {
34833491
frc = *pfrc;
34843492
*pfrc = (*pfrc)->next;
34853493
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
@@ -3497,8 +3505,8 @@ static ngtcp2_ssize conn_write_pkt(ngtcp2_conn *conn, ngtcp2_pkt_info *pi,
34973505
case NGTCP2_FRAME_STREAM_DATA_BLOCKED:
34983506
strm = ngtcp2_conn_find_stream(
34993507
conn, (*pfrc)->fr.stream_data_blocked.stream_id);
3500-
if (strm == NULL || (strm->flags & NGTCP2_STRM_FLAG_SHUT_WR) ||
3501-
(*pfrc)->fr.stream_data_blocked.offset != strm->tx.max_offset) {
3508+
if (strm == NULL || !ngtcp2_strm_require_retransmit_stream_data_blocked(
3509+
strm, &(*pfrc)->fr.stream_data_blocked)) {
35023510
frc = *pfrc;
35033511
*pfrc = (*pfrc)->next;
35043512
ngtcp2_frame_chain_objalloc_del(frc, &conn->frc_objalloc, conn->mem);
@@ -7145,7 +7153,7 @@ static int conn_recv_stream(ngtcp2_conn *conn, const ngtcp2_stream *fr) {
71457153
return rv;
71467154
}
71477155
}
7148-
} else if (fr->datacnt) {
7156+
} else if (fr->datacnt && !(strm->flags & NGTCP2_STRM_FLAG_STOP_SENDING)) {
71497157
rv = ngtcp2_strm_recv_reordering(strm, fr->data[0].base, fr->data[0].len,
71507158
fr->offset);
71517159
if (rv != 0) {
@@ -7304,27 +7312,20 @@ static int conn_recv_reset_stream(ngtcp2_conn *conn,
73047312
}
73057313

73067314
/* Stream is reset before we create ngtcp2_strm object. */
7307-
conn->rx.offset += fr->final_size;
7308-
ngtcp2_conn_extend_max_offset(conn, fr->final_size);
7309-
7310-
rv = conn_call_stream_reset(conn, fr->stream_id, fr->final_size,
7311-
fr->app_error_code, NULL);
7315+
strm = ngtcp2_objalloc_strm_get(&conn->strm_objalloc);
7316+
if (strm == NULL) {
7317+
return NGTCP2_ERR_NOMEM;
7318+
}
7319+
rv = ngtcp2_conn_init_stream(conn, strm, fr->stream_id, NULL);
73127320
if (rv != 0) {
7321+
ngtcp2_objalloc_strm_release(&conn->strm_objalloc, strm);
73137322
return rv;
73147323
}
73157324

7316-
/* There will be no activity in this stream because we got
7317-
RESET_STREAM and don't write stream data any further. This
7318-
effectively allows another new stream for peer. */
7319-
if (bidi) {
7320-
handle_max_remote_streams_extension(&conn->remote.bidi.unsent_max_streams,
7321-
1);
7322-
} else {
7323-
handle_max_remote_streams_extension(&conn->remote.uni.unsent_max_streams,
7324-
1);
7325+
rv = conn_call_stream_open(conn, strm);
7326+
if (rv != 0) {
7327+
return rv;
73257328
}
7326-
7327-
return 0;
73287329
}
73297330

73307331
if ((strm->flags & NGTCP2_STRM_FLAG_SHUT_RD)) {
@@ -7461,15 +7462,16 @@ static int conn_recv_stop_sending(ngtcp2_conn *conn,
74617462
been acknowledged. */
74627463
if (!ngtcp2_strm_is_all_tx_data_fin_acked(strm) &&
74637464
!(strm->flags & NGTCP2_STRM_FLAG_RESET_STREAM)) {
7465+
strm->flags |= NGTCP2_STRM_FLAG_RESET_STREAM;
7466+
74647467
rv = conn_reset_stream(conn, strm, fr->app_error_code);
74657468
if (rv != 0) {
74667469
return rv;
74677470
}
74687471
}
74697472

7470-
strm->flags |= NGTCP2_STRM_FLAG_SHUT_WR |
7471-
NGTCP2_STRM_FLAG_STOP_SENDING_RECVED |
7472-
NGTCP2_STRM_FLAG_RESET_STREAM;
7473+
strm->flags |=
7474+
NGTCP2_STRM_FLAG_SHUT_WR | NGTCP2_STRM_FLAG_STOP_SENDING_RECVED;
74737475

74747476
ngtcp2_strm_streamfrq_clear(strm);
74757477

@@ -12533,14 +12535,15 @@ static int conn_shutdown_stream_read(ngtcp2_conn *conn, ngtcp2_strm *strm,
1253312535

1253412536
/* Extend connection flow control window for the amount of data
1253512537
which are not passed to application. */
12536-
if (!(strm->flags & (NGTCP2_STRM_FLAG_STOP_SENDING |
12537-
NGTCP2_STRM_FLAG_RESET_STREAM_RECVED))) {
12538+
if (!(strm->flags & NGTCP2_STRM_FLAG_RESET_STREAM_RECVED)) {
1253812539
ngtcp2_conn_extend_max_offset(conn, strm->rx.last_offset -
1253912540
ngtcp2_strm_rx_offset(strm));
1254012541
}
1254112542

1254212543
strm->flags |= NGTCP2_STRM_FLAG_STOP_SENDING;
1254312544

12545+
ngtcp2_strm_discard_reordered_data(strm);
12546+
1254412547
return conn_stop_sending(conn, strm, app_error_code);
1254512548
}
1254612549

deps/ngtcp2/ngtcp2/lib/ngtcp2_crypto.c

Lines changed: 41 additions & 17 deletions

0 commit comments

Comments
 (0)