Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
deps: update nghttp3 to 1.4.0
  • Loading branch information
nodejs-github-bot committed Jun 16, 2024
commit 3a5151a30e70c7332b2f8ba5444ba39aff7e02bb
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.3.0"
#define NGHTTP3_VERSION "1.4.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 0x010300
#define NGHTTP3_VERSION_NUM 0x010400

#endif /* NGHTTP3_VERSION_H */
32 changes: 16 additions & 16 deletions deps/ngtcp2/nghttp3/lib/nghttp3_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int conn_new(nghttp3_conn **pconn, int server, int callbacks_version,

nghttp3_objalloc_init(&conn->out_chunk_objalloc,
NGHTTP3_STREAM_MIN_CHUNK_SIZE * 16, mem);
nghttp3_objalloc_stream_init(&conn->stream_objalloc, 64, mem);
nghttp3_objalloc_stream_init(&conn->stream_objalloc, 8, mem);

nghttp3_map_init(&conn->streams, mem);

Expand Down Expand Up @@ -419,7 +419,7 @@ nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn, int64_t stream_id,
}

conn->rx.max_stream_id_bidi =
nghttp3_max(conn->rx.max_stream_id_bidi, stream_id);
nghttp3_max_int64(conn->rx.max_stream_id_bidi, stream_id);
rv = nghttp3_conn_create_stream(conn, &stream, stream_id);
if (rv != 0) {
return rv;
Expand Down Expand Up @@ -767,7 +767,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
}

/* Read Identifier */
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
assert(len > 0);
nread = nghttp3_read_varint(rvint, p, len, frame_fin(rstate, len));
if (nread < 0) {
Expand Down Expand Up @@ -818,7 +818,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
}
break;
case NGHTTP3_CTRL_STREAM_STATE_SETTINGS_ID:
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
assert(len > 0);
nread = nghttp3_read_varint(rvint, p, len, frame_fin(rstate, len));
if (nread < 0) {
Expand All @@ -845,7 +845,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
}
/* Fall through */
case NGHTTP3_CTRL_STREAM_STATE_SETTINGS_VALUE:
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
assert(len > 0);
nread = nghttp3_read_varint(rvint, p, len, frame_fin(rstate, len));
if (nread < 0) {
Expand Down Expand Up @@ -879,7 +879,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
nghttp3_stream_read_state_reset(rstate);
break;
case NGHTTP3_CTRL_STREAM_STATE_GOAWAY:
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
assert(len > 0);
nread = nghttp3_read_varint(rvint, p, len, frame_fin(rstate, len));
if (nread < 0) {
Expand Down Expand Up @@ -916,7 +916,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
break;
case NGHTTP3_CTRL_STREAM_STATE_MAX_PUSH_ID:
/* server side only */
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
assert(len > 0);
nread = nghttp3_read_varint(rvint, p, len, frame_fin(rstate, len));
if (nread < 0) {
Expand All @@ -941,7 +941,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
break;
case NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE_PRI_ELEM_ID:
/* server side only */
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
assert(len > 0);
nread = nghttp3_read_varint(rvint, p, len, frame_fin(rstate, len));
if (nread < 0) {
Expand Down Expand Up @@ -977,7 +977,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
case NGHTTP3_CTRL_STREAM_STATE_PRIORITY_UPDATE:
/* We need to buffer Priority Field Value because it might be
fragmented. */
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
assert(len > 0);
if (conn->rx.pri_fieldbuflen == 0 && rstate->left == (int64_t)len) {
/* Everything is in the input buffer. Apply same length
Expand Down Expand Up @@ -1032,7 +1032,7 @@ nghttp3_ssize nghttp3_conn_read_control(nghttp3_conn *conn,
nghttp3_stream_read_state_reset(rstate);
break;
case NGHTTP3_CTRL_STREAM_STATE_IGN_FRAME:
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
p += len;
nconsumed += len;
rstate->left -= (int64_t)len;
Expand Down Expand Up @@ -1351,7 +1351,7 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc,
}
break;
case NGHTTP3_REQ_STREAM_STATE_DATA:
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
rv = nghttp3_conn_on_data(conn, stream, p, len);
if (rv != 0) {
return rv;
Expand All @@ -1370,7 +1370,7 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc,
nghttp3_stream_read_state_reset(rstate);
break;
case NGHTTP3_REQ_STREAM_STATE_HEADERS:
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
nread = nghttp3_conn_on_headers(conn, stream, p, len,
(int64_t)len == rstate->left);
if (nread < 0) {
Expand Down Expand Up @@ -1478,7 +1478,7 @@ nghttp3_ssize nghttp3_conn_read_bidi(nghttp3_conn *conn, size_t *pnproc,

break;
case NGHTTP3_REQ_STREAM_STATE_IGN_FRAME:
len = (size_t)nghttp3_min(rstate->left, (int64_t)(end - p));
len = (size_t)nghttp3_min_int64(rstate->left, (int64_t)(end - p));
p += len;
nconsumed += len;
rstate->left -= (int64_t)len;
Expand Down Expand Up @@ -1705,7 +1705,7 @@ int nghttp3_conn_on_settings_entry_received(nghttp3_conn *conn,
dest->qpack_blocked_streams = (size_t)ent->value;

nghttp3_qpack_encoder_set_max_blocked_streams(
&conn->qenc, (size_t)nghttp3_min(100, ent->value));
&conn->qenc, (size_t)nghttp3_min_uint64(100, ent->value));
break;
case NGHTTP3_SETTINGS_ID_ENABLE_CONNECT_PROTOCOL:
if (!conn->server) {
Expand Down Expand Up @@ -1784,7 +1784,7 @@ conn_on_priority_update_stream(nghttp3_conn *conn,
}

conn->rx.max_stream_id_bidi =
nghttp3_max(conn->rx.max_stream_id_bidi, stream_id);
nghttp3_max_int64(conn->rx.max_stream_id_bidi, stream_id);
rv = nghttp3_conn_create_stream(conn, &stream, stream_id);
if (rv != 0) {
return rv;
Expand Down Expand Up @@ -2319,7 +2319,7 @@ int nghttp3_conn_shutdown(nghttp3_conn *conn) {
frent.fr.hd.type = NGHTTP3_FRAME_GOAWAY;
if (conn->server) {
frent.fr.goaway.id =
nghttp3_min((1ll << 62) - 4, conn->rx.max_stream_id_bidi + 4);
nghttp3_min_int64((1ll << 62) - 4, conn->rx.max_stream_id_bidi + 4);
} else {
frent.fr.goaway.id = 0;
}
Expand Down
7 changes: 3 additions & 4 deletions deps/ngtcp2/nghttp3/lib/nghttp3_ksl.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ void nghttp3_ksl_init(nghttp3_ksl *ksl, nghttp3_ksl_compar compar,
size_t nodelen = ksl_nodelen(keylen);

nghttp3_objalloc_init(&ksl->blkalloc,
((ksl_blklen(nodelen) + 0xfu) & ~(uintptr_t)0xfu) * 8,
mem);
(ksl_blklen(nodelen) + 0xfu) & ~(uintptr_t)0xfu, mem);

ksl->head = NULL;
ksl->front = ksl->back = NULL;
Expand Down Expand Up @@ -826,6 +825,6 @@ int nghttp3_ksl_range_compar(const nghttp3_ksl_key *lhs,
int nghttp3_ksl_range_exclusive_compar(const nghttp3_ksl_key *lhs,
const nghttp3_ksl_key *rhs) {
const nghttp3_range *a = lhs, *b = rhs;
return a->begin < b->begin &&
!(nghttp3_max(a->begin, b->begin) < nghttp3_min(a->end, b->end));
return a->begin < b->begin && !(nghttp3_max_uint64(a->begin, b->begin) <
nghttp3_min_uint64(a->end, b->end));
}
2 changes: 1 addition & 1 deletion deps/ngtcp2/nghttp3/lib/nghttp3_ksl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
block can contain. */
#define NGHTTP3_KSL_MAX_NBLK (2 * NGHTTP3_KSL_DEGR - 1)
/* NGHTTP3_KSL_MIN_NBLK is the minimum number of nodes which a single
block other than root must contains. */
block other than root must contain. */
#define NGHTTP3_KSL_MIN_NBLK (NGHTTP3_KSL_DEGR - 1)

/*
Expand Down
29 changes: 26 additions & 3 deletions deps/ngtcp2/nghttp3/lib/nghttp3_macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@

#include <nghttp3/nghttp3.h>

#define nghttp3_min(A, B) ((A) < (B) ? (A) : (B))
#define nghttp3_max(A, B) ((A) > (B) ? (A) : (B))

#define nghttp3_struct_of(ptr, type, member) \
((type *)(void *)((char *)(ptr)-offsetof(type, member)))

Expand All @@ -48,4 +45,30 @@
variable-length integer encoding. */
#define NGHTTP3_MAX_VARINT ((1ULL << 62) - 1)

#define nghttp3_max_def(SUFFIX, T) \
static inline T nghttp3_max_##SUFFIX(T a, T b) { return a < b ? b : a; }

nghttp3_max_def(int8, int8_t);
nghttp3_max_def(int16, int16_t);
nghttp3_max_def(int32, int32_t);
nghttp3_max_def(int64, int64_t);
nghttp3_max_def(uint8, uint8_t);
nghttp3_max_def(uint16, uint16_t);
nghttp3_max_def(uint32, uint32_t);
nghttp3_max_def(uint64, uint64_t);
nghttp3_max_def(size, size_t);

#define nghttp3_min_def(SUFFIX, T) \
static inline T nghttp3_min_##SUFFIX(T a, T b) { return a < b ? a : b; }

nghttp3_min_def(int8, int8_t);
nghttp3_min_def(int16, int16_t);
nghttp3_min_def(int32, int32_t);
nghttp3_min_def(int64, int64_t);
nghttp3_min_def(uint8, uint8_t);
nghttp3_min_def(uint16, uint16_t);
nghttp3_min_def(uint32, uint32_t);
nghttp3_min_def(uint64, uint64_t);
nghttp3_min_def(size, size_t);

#endif /* NGHTTP3_MACRO_H */
2 changes: 1 addition & 1 deletion deps/ngtcp2/nghttp3/lib/nghttp3_pq.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ int nghttp3_pq_push(nghttp3_pq *pq, nghttp3_pq_entry *item) {
void *nq;
size_t ncapacity;

ncapacity = nghttp3_max(4, (pq->capacity * 2));
ncapacity = nghttp3_max_size(4, (pq->capacity * 2));

nq = nghttp3_mem_realloc(pq->mem, pq->q,
ncapacity * sizeof(nghttp3_pq_entry *));
Expand Down
41 changes: 21 additions & 20 deletions deps/ngtcp2/nghttp3/lib/nghttp3_qpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -952,8 +952,8 @@ void nghttp3_qpack_encoder_free(nghttp3_qpack_encoder *encoder) {

void nghttp3_qpack_encoder_set_max_dtable_capacity(
nghttp3_qpack_encoder *encoder, size_t max_dtable_capacity) {
max_dtable_capacity =
nghttp3_min(max_dtable_capacity, encoder->ctx.hard_max_dtable_capacity);
max_dtable_capacity = nghttp3_min_size(max_dtable_capacity,
encoder->ctx.hard_max_dtable_capacity);

if (encoder->ctx.max_dtable_capacity == max_dtable_capacity) {
return;
Expand Down Expand Up @@ -1377,7 +1377,7 @@ static int qpack_encoder_can_index(nghttp3_qpack_encoder *encoder, size_t need,

if (!nghttp3_pq_empty(&encoder->min_cnts)) {
gmin_cnt = nghttp3_qpack_encoder_get_min_cnt(encoder);
min_cnt = nghttp3_min(min_cnt, gmin_cnt);
min_cnt = nghttp3_min_uint64(min_cnt, gmin_cnt);
}

if (min_cnt == UINT64_MAX) {
Expand Down Expand Up @@ -1431,7 +1431,7 @@ static int qpack_encoder_can_index_duplicate(nghttp3_qpack_encoder *encoder,
static int qpack_context_check_draining(nghttp3_qpack_context *ctx,
uint64_t absidx) {
const size_t safe = ctx->max_dtable_capacity -
nghttp3_min(512, ctx->max_dtable_capacity * 1 / 8);
nghttp3_min_size(512, ctx->max_dtable_capacity * 1 / 8);
nghttp3_qpack_entry *ent = nghttp3_qpack_context_dtable_get(ctx, absidx);

return ctx->dtable_sum - ent->sum > safe;
Expand Down Expand Up @@ -1512,8 +1512,8 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder,
new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx);
dres.index = (nghttp3_ssize)new_ent->absidx;
}
*pmax_cnt = nghttp3_max(*pmax_cnt, (size_t)(dres.index + 1));
*pmin_cnt = nghttp3_min(*pmin_cnt, (size_t)(dres.index + 1));
*pmax_cnt = nghttp3_max_uint64(*pmax_cnt, (uint64_t)(dres.index + 1));
*pmin_cnt = nghttp3_min_uint64(*pmin_cnt, (uint64_t)(dres.index + 1));

return nghttp3_qpack_encoder_write_dynamic_indexed(
encoder, rbuf, (size_t)dres.index, base);
Expand All @@ -1533,8 +1533,8 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder,
}
if (allow_blocking) {
new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx);
*pmax_cnt = nghttp3_max(*pmax_cnt, new_ent->absidx + 1);
*pmin_cnt = nghttp3_min(*pmin_cnt, new_ent->absidx + 1);
*pmax_cnt = nghttp3_max_uint64(*pmax_cnt, new_ent->absidx + 1);
*pmin_cnt = nghttp3_min_uint64(*pmin_cnt, new_ent->absidx + 1);

return nghttp3_qpack_encoder_write_dynamic_indexed(
encoder, rbuf, new_ent->absidx, base);
Expand All @@ -1549,16 +1549,17 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder,
if (just_index &&
qpack_encoder_can_index_nv(
encoder, nv,
allow_blocking ? *pmin_cnt
: nghttp3_min((size_t)dres.index + 1, *pmin_cnt))) {
allow_blocking
? *pmin_cnt
: nghttp3_min_uint64((uint64_t)dres.index + 1, *pmin_cnt))) {
rv = nghttp3_qpack_encoder_write_dynamic_insert(encoder, ebuf,
(size_t)dres.index, nv);
if (rv != 0) {
return rv;
}

if (!allow_blocking) {
*pmin_cnt = nghttp3_min(*pmin_cnt, (size_t)dres.index + 1);
*pmin_cnt = nghttp3_min_uint64(*pmin_cnt, (uint64_t)dres.index + 1);
}

rv = nghttp3_qpack_encoder_dtable_dynamic_add(encoder, (size_t)dres.index,
Expand All @@ -1569,16 +1570,16 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder,

if (allow_blocking) {
new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx);
*pmax_cnt = nghttp3_max(*pmax_cnt, new_ent->absidx + 1);
*pmin_cnt = nghttp3_min(*pmin_cnt, new_ent->absidx + 1);
*pmax_cnt = nghttp3_max_uint64(*pmax_cnt, new_ent->absidx + 1);
*pmin_cnt = nghttp3_min_uint64(*pmin_cnt, new_ent->absidx + 1);

return nghttp3_qpack_encoder_write_dynamic_indexed(
encoder, rbuf, new_ent->absidx, base);
}
}

*pmax_cnt = nghttp3_max(*pmax_cnt, (size_t)(dres.index + 1));
*pmin_cnt = nghttp3_min(*pmin_cnt, (size_t)(dres.index + 1));
*pmax_cnt = nghttp3_max_uint64(*pmax_cnt, (uint64_t)(dres.index + 1));
*pmin_cnt = nghttp3_min_uint64(*pmin_cnt, (uint64_t)(dres.index + 1));

return nghttp3_qpack_encoder_write_dynamic_indexed_name(
encoder, rbuf, (size_t)dres.index, base, nv);
Expand All @@ -1595,8 +1596,8 @@ int nghttp3_qpack_encoder_encode_nv(nghttp3_qpack_encoder *encoder,
}
if (allow_blocking) {
new_ent = nghttp3_qpack_context_dtable_top(&encoder->ctx);
*pmax_cnt = nghttp3_max(*pmax_cnt, new_ent->absidx + 1);
*pmin_cnt = nghttp3_min(*pmin_cnt, new_ent->absidx + 1);
*pmax_cnt = nghttp3_max_uint64(*pmax_cnt, new_ent->absidx + 1);
*pmin_cnt = nghttp3_min_uint64(*pmin_cnt, new_ent->absidx + 1);

return nghttp3_qpack_encoder_write_dynamic_indexed(encoder, rbuf,
new_ent->absidx, base);
Expand Down Expand Up @@ -2735,7 +2736,7 @@ static nghttp3_ssize qpack_read_string(nghttp3_qpack_read_state *rstate,
nghttp3_buf *dest, const uint8_t *begin,
const uint8_t *end) {
size_t len = (size_t)(end - begin);
size_t n = (size_t)nghttp3_min((uint64_t)len, rstate->left);
size_t n = (size_t)nghttp3_min_uint64((uint64_t)len, rstate->left);

dest->last = nghttp3_cpymem(dest->last, begin, n);

Expand Down Expand Up @@ -3246,7 +3247,7 @@ int nghttp3_qpack_decoder_dtable_literal_add(nghttp3_qpack_decoder *decoder) {
void nghttp3_qpack_decoder_set_max_concurrent_streams(
nghttp3_qpack_decoder *decoder, size_t max_concurrent_streams) {
decoder->max_concurrent_streams =
nghttp3_max(decoder->max_concurrent_streams, max_concurrent_streams);
nghttp3_max_size(decoder->max_concurrent_streams, max_concurrent_streams);
}

void nghttp3_qpack_stream_context_init(nghttp3_qpack_stream_context *sctx,
Expand Down Expand Up @@ -3705,7 +3706,7 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder,
}

static int qpack_decoder_dbuf_overflow(nghttp3_qpack_decoder *decoder) {
size_t limit = nghttp3_max(decoder->max_concurrent_streams, 100);
size_t limit = nghttp3_max_size(decoder->max_concurrent_streams, 100);
/* 10 = nghttp3_qpack_put_varint_len((1ULL << 62) - 1, 2)) */
return nghttp3_buf_len(&decoder->dbuf) > limit * 2 * 10;
}
Expand Down
4 changes: 2 additions & 2 deletions deps/ngtcp2/nghttp3/lib/nghttp3_range.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ void nghttp3_range_init(nghttp3_range *r, uint64_t begin, uint64_t end) {
nghttp3_range nghttp3_range_intersect(const nghttp3_range *a,
const nghttp3_range *b) {
nghttp3_range r = {0, 0};
uint64_t begin = nghttp3_max(a->begin, b->begin);
uint64_t end = nghttp3_min(a->end, b->end);
uint64_t begin = nghttp3_max_uint64(a->begin, b->begin);
uint64_t end = nghttp3_min_uint64(a->end, b->end);
if (begin < end) {
nghttp3_range_init(&r, begin, end);
}
Expand Down
2 changes: 1 addition & 1 deletion deps/ngtcp2/nghttp3/lib/nghttp3_ringbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void nghttp3_ringbuf_free(nghttp3_ringbuf *rb) {

void *nghttp3_ringbuf_push_front(nghttp3_ringbuf *rb) {
rb->first = (rb->first - 1) & (rb->nmemb - 1);
rb->len = nghttp3_min(rb->nmemb, rb->len + 1);
rb->len = nghttp3_min_size(rb->nmemb, rb->len + 1);

return (void *)&rb->buf[rb->first * rb->size];
}
Expand Down
Loading