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.3.0
  • Loading branch information
nodejs-github-bot committed May 12, 2024
commit ac76b5bd8b4e6b178dc85e914ac4a202d3c478a6
20 changes: 11 additions & 9 deletions deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h
Original file line number Diff line number Diff line change
Expand Up @@ -2118,9 +2118,10 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
* User callback failed.
*
* It may return the other error codes. In general, the negative
* error code means that |conn| encountered a connection error, and
* the connection should be closed.
* It may return the other error codes. The negative error code means
* that |conn| encountered a connection error, and the connection must
* be closed. Calling nghttp3 API other than `nghttp3_conn_del`
* causes undefined behavior.
*/
NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn,
int64_t stream_id,
Expand Down Expand Up @@ -2152,9 +2153,10 @@ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn,
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
* User callback failed.
*
* It may return the other error codes. In general, the negative
* error code means that |conn| encountered a connection error, and
* the connection should be closed.
* It may return the other error codes. The negative error code means
* that |conn| encountered a connection error, and the connection must
* be closed. Calling nghttp3 API other than `nghttp3_conn_del`
* causes undefined behavior.
*/
NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_writev_stream(nghttp3_conn *conn,
int64_t *pstream_id,
Expand Down Expand Up @@ -2339,9 +2341,9 @@ NGHTTP3_EXTERN int nghttp3_conn_resume_stream(nghttp3_conn *conn,
/**
* @function
*
* `nghttp3_conn_close_stream` closes stream identified by
* |stream_id|. QUIC application error code |app_error_code| is the
* reason of the closure.
* `nghttp3_conn_close_stream` tells the library that a stream
* identified by |stream_id| has been closed. QUIC application error
* code |app_error_code| is the reason of the closure.
*
* This function returns 0 if it succeeds, or one of the following
* negative error codes:
Expand Down
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.2.0"
#define NGHTTP3_VERSION "1.3.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 0x010200
#define NGHTTP3_VERSION_NUM 0x010300

#endif /* NGHTTP3_VERSION_H */
17 changes: 16 additions & 1 deletion deps/ngtcp2/nghttp3/lib/nghttp3_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2095,7 +2095,22 @@ int nghttp3_conn_add_ack_offset(nghttp3_conn *conn, int64_t stream_id,
return 0;
}

return nghttp3_stream_add_ack_offset(stream, n);
return nghttp3_stream_update_ack_offset(stream, stream->ack_offset + n);
}

int nghttp3_conn_update_ack_offset(nghttp3_conn *conn, int64_t stream_id,
uint64_t offset) {
nghttp3_stream *stream = nghttp3_conn_find_stream(conn, stream_id);

if (stream == NULL) {
return 0;
}

if (stream->ack_offset > offset) {
return NGHTTP3_ERR_INVALID_ARGUMENT;
}

return nghttp3_stream_update_ack_offset(stream, offset);
}

int nghttp3_conn_update_ack_offset(nghttp3_conn *conn, int64_t stream_id,
Expand Down
16 changes: 16 additions & 0 deletions deps/ngtcp2/nghttp3/lib/nghttp3_qpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@ int nghttp3_qpack_encoder_init(nghttp3_qpack_encoder *encoder,
encoder->opcode = 0;
encoder->min_dtable_update = SIZE_MAX;
encoder->last_max_dtable_update = 0;
encoder->uninterrupted_decoderlen = 0;
encoder->flags = NGHTTP3_QPACK_ENCODER_FLAG_NONE;

nghttp3_qpack_read_state_reset(&encoder->rstate);
Expand Down Expand Up @@ -1181,6 +1182,8 @@ int nghttp3_qpack_encoder_encode(nghttp3_qpack_encoder *encoder,
nghttp3_qpack_encoder_write_field_section_prefix(encoder, pbuf, max_cnt,
base);

encoder->uninterrupted_decoderlen = 0;

/* TODO If max_cnt == 0, no reference is made to dtable. */
if (!max_cnt) {
return 0;
Expand Down Expand Up @@ -2523,6 +2526,11 @@ nghttp3_ssize nghttp3_qpack_encoder_read_decoder(nghttp3_qpack_encoder *encoder,
return 0;
}

encoder->uninterrupted_decoderlen += srclen;
if (encoder->uninterrupted_decoderlen > NGHTTP3_QPACK_MAX_DECODERLEN) {
return NGHTTP3_ERR_QPACK_DECODER_STREAM_ERROR;
}

end = src + srclen;

for (; p != end;) {
Expand Down Expand Up @@ -2670,6 +2678,7 @@ int nghttp3_qpack_decoder_init(nghttp3_qpack_decoder *decoder,
decoder->opcode = 0;
decoder->written_icnt = 0;
decoder->max_concurrent_streams = 0;
decoder->uninterrupted_encoderlen = 0;

nghttp3_qpack_read_state_reset(&decoder->rstate);
nghttp3_buf_init(&decoder->dbuf);
Expand Down Expand Up @@ -2789,6 +2798,11 @@ nghttp3_ssize nghttp3_qpack_decoder_read_encoder(nghttp3_qpack_decoder *decoder,
return 0;
}

decoder->uninterrupted_encoderlen += srclen;
if (decoder->uninterrupted_encoderlen > NGHTTP3_QPACK_MAX_ENCODERLEN) {
return NGHTTP3_ERR_QPACK_ENCODER_STREAM_ERROR;
}

end = src + srclen;

for (; p != end || busy;) {
Expand Down Expand Up @@ -3679,6 +3693,8 @@ nghttp3_qpack_decoder_read_request(nghttp3_qpack_decoder *decoder,
goto fail;
}
}

decoder->uninterrupted_encoderlen = 0;
}

return p - src;
Expand Down
14 changes: 14 additions & 0 deletions deps/ngtcp2/nghttp3/lib/nghttp3_qpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
/* NGHTTP3_QPACK_MAX_VALUELEN is the maximum (compressed) length of
header value this library can decode. */
#define NGHTTP3_QPACK_MAX_VALUELEN 65536
/* NGHTTP3_QPACK_MAX_ENCODERLEN is the maximum encoder stream length
that a decoder accepts without completely processing a single field
section. */
#define NGHTTP3_QPACK_MAX_ENCODERLEN (128 * 1024)
/* NGHTTP3_QPACK_MAX_DECODERLEN is the maximum decoder stream length
that an encoder accepts without completely encoding a single field
section. */
#define NGHTTP3_QPACK_MAX_DECODERLEN (4 * 1024)

/* nghttp3_qpack_indexing_mode is a indexing strategy. */
typedef enum nghttp3_qpack_indexing_mode {
Expand Down Expand Up @@ -250,6 +258,9 @@ struct nghttp3_qpack_encoder {
/* last_max_dtable_update is the dynamic table size last
requested. */
size_t last_max_dtable_update;
/* uninterrupted_decoderlen is the number of bytes read from decoder
stream without encoding a single field section. */
size_t uninterrupted_decoderlen;
/* flags is bitwise OR of zero or more of
NGHTTP3_QPACK_ENCODER_FLAG_*. */
uint8_t flags;
Expand Down Expand Up @@ -779,6 +790,9 @@ struct nghttp3_qpack_decoder {
unidirectional streams which potentially receives QPACK encoded
HEADER frame. */
size_t max_concurrent_streams;
/* uninterrupted_encoderlen is the number of bytes read from encoder
stream without completing a single field section. */
size_t uninterrupted_encoderlen;
};

/*
Expand Down
4 changes: 3 additions & 1 deletion deps/ngtcp2/nghttp3/lib/nghttp3_qpack_huffman.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ nghttp3_qpack_huffman_decode(nghttp3_qpack_huffman_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 = &qpack_huffman_decode_table[t->fstate & 0x1ff][c >> 4];
Expand Down
29 changes: 14 additions & 15 deletions deps/ngtcp2/nghttp3/lib/nghttp3_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ int nghttp3_stream_new(nghttp3_stream **pstream, int64_t stream_id,

stream->qpack_blocked_pe.index = NGHTTP3_PQ_BAD_INDEX;
stream->mem = mem;
stream->tx.offset = 0;
stream->rx.http.status_code = -1;
stream->rx.http.content_length = -1;
stream->rx.http.pri.urgency = NGHTTP3_DEFAULT_URGENCY;
Expand Down Expand Up @@ -928,9 +927,8 @@ static void stream_pop_outq_entry(nghttp3_stream *stream,
nghttp3_ringbuf_pop_front(&stream->outq);
}

int nghttp3_stream_add_ack_offset(nghttp3_stream *stream, uint64_t n) {
int nghttp3_stream_update_ack_offset(nghttp3_stream *stream, uint64_t offset) {
nghttp3_ringbuf *outq = &stream->outq;
uint64_t offset = stream->ack_offset + n;
size_t buflen;
size_t npopped = 0;
uint64_t nack;
Expand All @@ -941,24 +939,25 @@ int nghttp3_stream_add_ack_offset(nghttp3_stream *stream, uint64_t n) {
tbuf = nghttp3_ringbuf_get(outq, 0);
buflen = nghttp3_buf_len(&tbuf->buf);

if (tbuf->type == NGHTTP3_BUF_TYPE_ALIEN) {
nack = nghttp3_min(offset, (uint64_t)buflen) - stream->ack_done;
if (stream->callbacks.acked_data) {
rv = stream->callbacks.acked_data(stream, stream->node.id, nack,
stream->user_data);
if (rv != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE;
}
/* For NGHTTP3_BUF_TYPE_ALIEN, we never add 0 length buffer. */
if (tbuf->type == NGHTTP3_BUF_TYPE_ALIEN && stream->ack_offset < offset &&
stream->callbacks.acked_data) {
nack =
nghttp3_min(offset, stream->ack_base + buflen) - stream->ack_offset;

rv = stream->callbacks.acked_data(stream, stream->node.id, nack,
stream->user_data);
if (rv != 0) {
return NGHTTP3_ERR_CALLBACK_FAILURE;
}
stream->ack_done += nack;
}

if (offset >= buflen) {
if (offset >= stream->ack_base + buflen) {
stream_pop_outq_entry(stream, tbuf);

offset -= buflen;
stream->ack_base += buflen;
stream->ack_offset = stream->ack_base;
++npopped;
stream->ack_done = 0;

if (stream->outq_idx + 1 == npopped) {
stream->outq_offset = 0;
Expand Down
20 changes: 10 additions & 10 deletions deps/ngtcp2/nghttp3/lib/nghttp3_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,12 @@ struct nghttp3_stream {
/* outq_offset is write offset relative to the element at outq_idx
in outq. */
uint64_t outq_offset;
/* ack_offset is offset acknowledged by peer relative to the first
element in outq. */
/* ack_base is the number of bytes acknowledged by a remote
endpoint where the first element in outq is positioned at. */
uint64_t ack_base;
/* ack_offset is the number of bytes acknowledged by a remote
endpoint so far. */
uint64_t ack_offset;
/* ack_done is the number of bytes notified to an application that
they are acknowledged inside the first outq element if it is of
type NGHTTP3_BUF_TYPE_ALIEN. */
uint64_t ack_done;
/* ack_total is the cumulative number of bytes acknowledged so
far. */
uint64_t ack_total;
uint64_t unscheduled_nwrite;
nghttp3_stream_type type;
nghttp3_stream_read_state rstate;
Expand Down Expand Up @@ -339,7 +335,11 @@ void nghttp3_stream_add_outq_offset(nghttp3_stream *stream, size_t n);
*/
int nghttp3_stream_outq_write_done(nghttp3_stream *stream);

int nghttp3_stream_add_ack_offset(nghttp3_stream *stream, uint64_t n);
/*
* nghttp2_stream_update_ack_offset updates the last acknowledged
* offset to |offset|.
*/
int nghttp3_stream_update_ack_offset(nghttp3_stream *stream, uint64_t offset);

/*
* nghttp3_stream_is_active returns nonzero if |stream| is active. In
Expand Down