Skip to content

Commit

Permalink
deps: update nghttp2 to 1.62.0
Browse files Browse the repository at this point in the history
PR-URL: #52966
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ulises Gascón <[email protected]>
  • Loading branch information
nodejs-github-bot authored and RafaelGSS committed Jun 7, 2024
1 parent ec83431 commit fc94992
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 44 deletions.
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ EXTRACFLAG = @EXTRACFLAG@
EXTRA_DEFS = @EXTRA_DEFS@
FGREP = @FGREP@
GREP = @GREP@
HAVE_CXX14 = @HAVE_CXX14@
HAVE_CXX20 = @HAVE_CXX20@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
Expand Down
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/includes/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ EXTRACFLAG = @EXTRACFLAG@
EXTRA_DEFS = @EXTRA_DEFS@
FGREP = @FGREP@
GREP = @GREP@
HAVE_CXX14 = @HAVE_CXX14@
HAVE_CXX20 = @HAVE_CXX20@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
Expand Down
4 changes: 2 additions & 2 deletions deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
* @macro
* Version number of the nghttp2 library release
*/
#define NGHTTP2_VERSION "1.61.0"
#define NGHTTP2_VERSION "1.62.0"

/**
* @macro
* Numerical representation of the version number of the nghttp2 library
* release. This is a 24 bit number with 8 bits for major number, 8 bits
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
*/
#define NGHTTP2_VERSION_NUM 0x013d00
#define NGHTTP2_VERSION_NUM 0x013e00

#endif /* NGHTTP2VER_H */
4 changes: 2 additions & 2 deletions deps/nghttp2/lib/nghttp2_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int nghttp2_buf_reserve(nghttp2_buf *buf, size_t new_cap, nghttp2_mem *mem) {
return 0;
}

new_cap = nghttp2_max(new_cap, cap * 2);
new_cap = nghttp2_max_size(new_cap, cap * 2);

ptr = nghttp2_mem_realloc(mem, buf->begin, new_cap);
if (ptr == NULL) {
Expand Down Expand Up @@ -343,7 +343,7 @@ int nghttp2_bufs_add(nghttp2_bufs *bufs, const void *data, size_t len) {
while (len) {
buf = &bufs->cur->buf;

nwrite = nghttp2_min(nghttp2_buf_avail(buf), len);
nwrite = nghttp2_min_size(nghttp2_buf_avail(buf), len);
if (nwrite == 0) {
rv = bufs_alloc_chain(bufs);
if (rv != 0) {
Expand Down
12 changes: 6 additions & 6 deletions deps/nghttp2/lib/nghttp2_hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,13 +1245,13 @@ static void hd_context_shrink_table_size(nghttp2_hd_context *context,

int nghttp2_hd_deflate_change_table_size(
nghttp2_hd_deflater *deflater, size_t settings_max_dynamic_table_size) {
size_t next_bufsize = nghttp2_min(settings_max_dynamic_table_size,
deflater->deflate_hd_table_bufsize_max);
size_t next_bufsize = nghttp2_min_size(
settings_max_dynamic_table_size, deflater->deflate_hd_table_bufsize_max);

deflater->ctx.hd_table_bufsize_max = next_bufsize;

deflater->min_hd_table_bufsize_max =
nghttp2_min(deflater->min_hd_table_bufsize_max, next_bufsize);
nghttp2_min_size(deflater->min_hd_table_bufsize_max, next_bufsize);

deflater->notify_table_size_change = 1;

Expand Down Expand Up @@ -1738,7 +1738,7 @@ static nghttp2_ssize hd_inflate_read_huff(nghttp2_hd_inflater *inflater,
static nghttp2_ssize hd_inflate_read(nghttp2_hd_inflater *inflater,
nghttp2_buf *buf, const uint8_t *in,
const uint8_t *last) {
size_t len = nghttp2_min((size_t)(last - in), inflater->left);
size_t len = nghttp2_min_size((size_t)(last - in), inflater->left);

buf->last = nghttp2_cpymem(buf->last, in, len);

Expand Down Expand Up @@ -1962,8 +1962,8 @@ nghttp2_ssize nghttp2_hd_inflate_hd_nv(nghttp2_hd_inflater *inflater,
rfin = 0;
rv = hd_inflate_read_len(
inflater, &rfin, in, last, 5,
nghttp2_min(inflater->min_hd_table_bufsize_max,
inflater->settings_hd_table_bufsize_max));
nghttp2_min_size(inflater->min_hd_table_bufsize_max,
inflater->settings_hd_table_bufsize_max));
if (rv < 0) {
goto fail;
}
Expand Down
4 changes: 3 additions & 1 deletion deps/nghttp2/lib/nghttp2_hd_huffman.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ nghttp2_ssize nghttp2_hd_huff_decode(nghttp2_hd_huff_decode_context *ctx,
uint8_t c;

/* We use the decoding algorithm described in
http://graphics.ics.uci.edu/pub/Prefix.pdf */
- http://graphics.ics.uci.edu/pub/Prefix.pdf [!!! NO LONGER VALID !!!]
- https://ics.uci.edu/~dan/pubs/Prefix.pdf
- https://github.com/nghttp2/nghttp2/files/15141264/Prefix.pdf */
for (; src != end;) {
c = *src++;
t = &huff_decode_table[t->fstate & 0x1ff][c >> 4];
Expand Down
6 changes: 3 additions & 3 deletions deps/nghttp2/lib/nghttp2_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
int32_t recv_reduction_delta;
int32_t delta;
int32_t new_recv_window_size =
nghttp2_max(0, *recv_window_size_ptr) - *delta_ptr;
nghttp2_max_int32(0, *recv_window_size_ptr) - *delta_ptr;

if (new_recv_window_size >= 0) {
*recv_window_size_ptr = new_recv_window_size;
Expand All @@ -177,7 +177,7 @@ int nghttp2_adjust_local_window_size(int32_t *local_window_size_ptr,
*local_window_size_ptr += delta;
/* If there is recv_reduction due to earlier window_size
reduction, we have to adjust it too. */
recv_reduction_delta = nghttp2_min(*recv_reduction_ptr, delta);
recv_reduction_delta = nghttp2_min_int32(*recv_reduction_ptr, delta);
*recv_reduction_ptr -= recv_reduction_delta;
if (*recv_window_size_ptr < 0) {
*recv_window_size_ptr += recv_reduction_delta;
Expand Down Expand Up @@ -233,7 +233,7 @@ int nghttp2_increase_local_window_size(int32_t *local_window_size_ptr,
*local_window_size_ptr += delta;
/* If there is recv_reduction due to earlier window_size
reduction, we have to adjust it too. */
recv_reduction_delta = nghttp2_min(*recv_reduction_ptr, delta);
recv_reduction_delta = nghttp2_min_int32(*recv_reduction_ptr, delta);
*recv_reduction_ptr -= recv_reduction_delta;

*recv_window_size_ptr += recv_reduction_delta;
Expand Down
27 changes: 25 additions & 2 deletions deps/nghttp2/lib/nghttp2_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,31 @@
#include <nghttp2/nghttp2.h>
#include "nghttp2_mem.h"

#define nghttp2_min(A, B) ((A) < (B) ? (A) : (B))
#define nghttp2_max(A, B) ((A) > (B) ? (A) : (B))
#define nghttp2_max_def(SUFFIX, T) \
static inline T nghttp2_max_##SUFFIX(T a, T b) { return a < b ? b : a; }

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

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

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

#define lstreq(A, B, N) ((sizeof((A)) - 1) == (N) && memcmp((A), (B), (N)) == 0)

Expand Down
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/nghttp2_pq.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int nghttp2_pq_push(nghttp2_pq *pq, nghttp2_pq_entry *item) {
void *nq;
size_t ncapacity;

ncapacity = nghttp2_max(4, (pq->capacity * 2));
ncapacity = nghttp2_max_size(4, (pq->capacity * 2));

nq = nghttp2_mem_realloc(pq->mem, pq->q,
ncapacity * sizeof(nghttp2_pq_entry *));
Expand Down
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/nghttp2_ratelim.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void nghttp2_ratelim_update(nghttp2_ratelim *rl, uint64_t tstamp) {
}

rl->val += gain;
rl->val = nghttp2_min(rl->val, rl->burst);
rl->val = nghttp2_min_uint64(rl->val, rl->burst);
}

int nghttp2_ratelim_drain(nghttp2_ratelim *rl, uint64_t n) {
Expand Down
47 changes: 26 additions & 21 deletions deps/nghttp2/lib/nghttp2_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -1700,10 +1700,11 @@ int nghttp2_session_adjust_idle_stream(nghttp2_session *session) {

/* Make minimum number of idle streams 16, and maximum 100, which
are arbitrary chosen numbers. */
max = nghttp2_min(
100, nghttp2_max(
16, nghttp2_min(session->local_settings.max_concurrent_streams,
session->pending_local_max_concurrent_stream)));
max = nghttp2_min_uint32(
100, nghttp2_max_uint32(
16, nghttp2_min_uint32(
session->local_settings.max_concurrent_streams,
session->pending_local_max_concurrent_stream)));

DEBUGF("stream: adjusting kept idle streams num_idle_streams=%zu, max=%zu\n",
session->num_idle_streams, max);
Expand Down Expand Up @@ -2131,10 +2132,11 @@ static nghttp2_ssize nghttp2_session_enforce_flow_control_limits(
session->remote_window_size, session->remote_settings.max_frame_size,
stream->stream_id, stream->remote_window_size);

return nghttp2_min(nghttp2_min(nghttp2_min(requested_window_size,
stream->remote_window_size),
session->remote_window_size),
(int32_t)session->remote_settings.max_frame_size);
return nghttp2_min_int32(
nghttp2_min_int32(nghttp2_min_int32((int32_t)requested_window_size,
stream->remote_window_size),
session->remote_window_size),
(int32_t)session->remote_settings.max_frame_size);
}

/*
Expand Down Expand Up @@ -2218,7 +2220,7 @@ static nghttp2_ssize session_call_select_padding(nghttp2_session *session,
}

max_paddedlen =
nghttp2_min(frame->hd.length + NGHTTP2_MAX_PADLEN, max_payloadlen);
nghttp2_min_size(frame->hd.length + NGHTTP2_MAX_PADLEN, max_payloadlen);

if (session->callbacks.select_padding_callback2) {
rv = session->callbacks.select_padding_callback2(
Expand Down Expand Up @@ -2248,8 +2250,8 @@ static int session_headers_add_pad(nghttp2_session *session,
aob = &session->aob;
framebufs = &aob->framebufs;

max_payloadlen = nghttp2_min(NGHTTP2_MAX_PAYLOADLEN,
frame->hd.length + NGHTTP2_MAX_PADLEN);
max_payloadlen = nghttp2_min_size(NGHTTP2_MAX_PAYLOADLEN,
frame->hd.length + NGHTTP2_MAX_PADLEN);

padded_payloadlen =
session_call_select_padding(session, frame, max_payloadlen);
Expand Down Expand Up @@ -2289,7 +2291,7 @@ static int session_pack_extension(nghttp2_session *session, nghttp2_bufs *bufs,
session->callbacks.pack_extension_callback);

buf = &bufs->head->buf;
buflen = nghttp2_min(nghttp2_buf_avail(buf), NGHTTP2_MAX_PAYLOADLEN);
buflen = nghttp2_min_size(nghttp2_buf_avail(buf), NGHTTP2_MAX_PAYLOADLEN);

if (session->callbacks.pack_extension_callback2) {
rv = session->callbacks.pack_extension_callback2(session, buf->last, buflen,
Expand Down Expand Up @@ -4708,7 +4710,8 @@ int nghttp2_session_update_local_settings(nghttp2_session *session,
case NGHTTP2_SETTINGS_HEADER_TABLE_SIZE:
header_table_size_seen = 1;
header_table_size = iv[i].value;
min_header_table_size = nghttp2_min(min_header_table_size, iv[i].value);
min_header_table_size =
nghttp2_min_uint32(min_header_table_size, iv[i].value);
break;
case NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE:
new_initial_window_size = (int32_t)iv[i].value;
Expand Down Expand Up @@ -5594,7 +5597,7 @@ static int session_update_consumed_size(nghttp2_session *session,
/* recv_window_size may be smaller than consumed_size, because it
may be decreased by negative value with
nghttp2_submit_window_update(). */
recv_size = nghttp2_min(*consumed_size_ptr, *recv_window_size_ptr);
recv_size = nghttp2_min_int32(*consumed_size_ptr, *recv_window_size_ptr);

if (nghttp2_should_send_window_update(local_window_size, recv_size)) {
rv = nghttp2_session_add_window_update(session, NGHTTP2_FLAG_NONE,
Expand Down Expand Up @@ -5717,7 +5720,7 @@ static int session_on_data_received_fail_fast(nghttp2_session *session) {
static size_t inbound_frame_payload_readlen(nghttp2_inbound_frame *iframe,
const uint8_t *in,
const uint8_t *last) {
return nghttp2_min((size_t)(last - in), iframe->payloadleft);
return nghttp2_min_size((size_t)(last - in), iframe->payloadleft);
}

/*
Expand All @@ -5732,8 +5735,8 @@ static size_t inbound_frame_buf_read(nghttp2_inbound_frame *iframe,
const uint8_t *in, const uint8_t *last) {
size_t readlen;

readlen =
nghttp2_min((size_t)(last - in), nghttp2_buf_mark_avail(&iframe->sbuf));
readlen = nghttp2_min_size((size_t)(last - in),
nghttp2_buf_mark_avail(&iframe->sbuf));

iframe->sbuf.last = nghttp2_cpymem(iframe->sbuf.last, in, readlen);

Expand Down Expand Up @@ -5900,7 +5903,7 @@ nghttp2_ssize nghttp2_session_mem_recv2(nghttp2_session *session,
for (;;) {
switch (iframe->state) {
case NGHTTP2_IB_READ_CLIENT_MAGIC:
readlen = nghttp2_min(inlen, iframe->payloadleft);
readlen = nghttp2_min_size(inlen, iframe->payloadleft);

if (memcmp(&NGHTTP2_CLIENT_MAGIC[NGHTTP2_CLIENT_MAGIC_LEN -
iframe->payloadleft],
Expand Down Expand Up @@ -7509,7 +7512,8 @@ int nghttp2_session_add_goaway(nghttp2_session *session, int32_t last_stream_id,

/* last_stream_id must not be increased from the value previously
sent */
last_stream_id = nghttp2_min(last_stream_id, session->local_last_stream_id);
last_stream_id =
nghttp2_min_int32(last_stream_id, session->local_last_stream_id);

nghttp2_frame_goaway_init(&frame->goaway, last_stream_id, error_code,
opaque_data_copy, opaque_data_len);
Expand Down Expand Up @@ -7823,7 +7827,8 @@ int nghttp2_session_pack_data(nghttp2_session *session, nghttp2_bufs *bufs,
frame->hd.length = (size_t)payloadlen;
frame->data.padlen = 0;

max_payloadlen = nghttp2_min(datamax, frame->hd.length + NGHTTP2_MAX_PADLEN);
max_payloadlen =
nghttp2_min_size(datamax, frame->hd.length + NGHTTP2_MAX_PADLEN);

padded_payloadlen =
session_call_select_padding(session, frame, max_payloadlen);
Expand Down Expand Up @@ -7997,7 +8002,7 @@ int32_t nghttp2_session_get_stream_remote_window_size(nghttp2_session *session,

/* stream->remote_window_size can be negative when
SETTINGS_INITIAL_WINDOW_SIZE is changed. */
return nghttp2_max(0, stream->remote_window_size);
return nghttp2_max_int32(0, stream->remote_window_size);
}

int32_t nghttp2_session_get_remote_window_size(nghttp2_session *session) {
Expand Down
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/nghttp2_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ int32_t nghttp2_stream_dep_distributed_weight(nghttp2_stream *stream,
int32_t weight) {
weight = stream->weight * weight / stream->sum_dep_weight;

return nghttp2_max(1, weight);
return nghttp2_max_int32(1, weight);
}

#ifdef STREAM_DEP_DEBUG
Expand Down
4 changes: 2 additions & 2 deletions deps/nghttp2/lib/nghttp2_submit.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,10 @@ int nghttp2_submit_window_update(nghttp2_session *session, uint8_t flags,
if (window_size_increment > 0) {
if (stream_id == 0) {
session->consumed_size =
nghttp2_max(0, session->consumed_size - window_size_increment);
nghttp2_max_int32(0, session->consumed_size - window_size_increment);
} else {
stream->consumed_size =
nghttp2_max(0, stream->consumed_size - window_size_increment);
nghttp2_max_int32(0, stream->consumed_size - window_size_increment);
}

return nghttp2_session_add_window_update(session, 0, stream_id,
Expand Down

0 comments on commit fc94992

Please sign in to comment.