Skip to content

Commit 9acc7f3

Browse files
jasnellMylesBorins
authored andcommitted
deps: update nghttp2 to 1.29.0
Backport-PR-URL: #20456 PR-URL: #17908 Refs: #17746 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent a1539e5 commit 9acc7f3

15 files changed

+128
-45
lines changed

deps/nghttp2/lib/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ set_target_properties(nghttp2 PROPERTIES
4444
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
4545
C_VISIBILITY_PRESET hidden
4646
)
47+
target_include_directories(nghttp2 INTERFACE
48+
"${CMAKE_CURRENT_BINARY_DIR}/includes"
49+
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
50+
)
4751

4852
if(HAVE_CUNIT)
4953
# Static library (for unittests because of symbol visibility)

deps/nghttp2/lib/includes/nghttp2/nghttp2.h

+59-4
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ typedef enum {
387387
* Indicates that a processing was canceled.
388388
*/
389389
NGHTTP2_ERR_CANCEL = -535,
390+
/**
391+
* When a local endpoint expects to receive SETTINGS frame, it
392+
* receives an other type of frame.
393+
*/
394+
NGHTTP2_ERR_SETTINGS_EXPECTED = -536,
390395
/**
391396
* The errors < :enum:`NGHTTP2_ERR_FATAL` mean that the library is
392397
* under unexpected condition and processing was terminated (e.g.,
@@ -1987,6 +1992,9 @@ typedef ssize_t (*nghttp2_pack_extension_callback)(nghttp2_session *session,
19871992
* of length |len|. |len| does not include the sentinel NULL
19881993
* character.
19891994
*
1995+
* This function is deprecated. The new application should use
1996+
* :type:`nghttp2_error_callback2`.
1997+
*
19901998
* The format of error message may change between nghttp2 library
19911999
* versions. The application should not depend on the particular
19922000
* format.
@@ -2003,6 +2011,33 @@ typedef ssize_t (*nghttp2_pack_extension_callback)(nghttp2_session *session,
20032011
typedef int (*nghttp2_error_callback)(nghttp2_session *session, const char *msg,
20042012
size_t len, void *user_data);
20052013

2014+
/**
2015+
* @functypedef
2016+
*
2017+
* Callback function invoked when library provides the error code, and
2018+
* message. This callback is solely for debugging purpose.
2019+
* |lib_error_code| is one of error code defined in
2020+
* :enum:`nghttp2_error`. The |msg| is typically NULL-terminated
2021+
* string of length |len|, and intended for human consumption. |len|
2022+
* does not include the sentinel NULL character.
2023+
*
2024+
* The format of error message may change between nghttp2 library
2025+
* versions. The application should not depend on the particular
2026+
* format.
2027+
*
2028+
* Normally, application should return 0 from this callback. If fatal
2029+
* error occurred while doing something in this callback, application
2030+
* should return :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. In this case,
2031+
* library will return immediately with return value
2032+
* :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`. Currently, if nonzero value
2033+
* is returned from this callback, they are treated as
2034+
* :enum:`NGHTTP2_ERR_CALLBACK_FAILURE`, but application should not
2035+
* rely on this details.
2036+
*/
2037+
typedef int (*nghttp2_error_callback2)(nghttp2_session *session,
2038+
int lib_error_code, const char *msg,
2039+
size_t len, void *user_data);
2040+
20062041
struct nghttp2_session_callbacks;
20072042

20082043
/**
@@ -2267,10 +2302,30 @@ nghttp2_session_callbacks_set_on_extension_chunk_recv_callback(
22672302
*
22682303
* Sets callback function invoked when library tells error message to
22692304
* the application.
2305+
*
2306+
* This function is deprecated. The new application should use
2307+
* `nghttp2_session_callbacks_set_error_callback2()`.
2308+
*
2309+
* If both :type:`nghttp2_error_callback` and
2310+
* :type:`nghttp2_error_callback2` are set, the latter takes
2311+
* precedence.
22702312
*/
22712313
NGHTTP2_EXTERN void nghttp2_session_callbacks_set_error_callback(
22722314
nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback);
22732315

2316+
/**
2317+
* @function
2318+
*
2319+
* Sets callback function invoked when library tells error code, and
2320+
* message to the application.
2321+
*
2322+
* If both :type:`nghttp2_error_callback` and
2323+
* :type:`nghttp2_error_callback2` are set, the latter takes
2324+
* precedence.
2325+
*/
2326+
NGHTTP2_EXTERN void nghttp2_session_callbacks_set_error_callback2(
2327+
nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2);
2328+
22742329
/**
22752330
* @functypedef
22762331
*
@@ -4702,8 +4757,8 @@ nghttp2_hd_deflate_change_table_size(nghttp2_hd_deflater *deflater,
47024757
*
47034758
* After this function returns, it is safe to delete the |nva|.
47044759
*
4705-
* This function returns 0 if it succeeds, or one of the following
4706-
* negative error codes:
4760+
* This function returns the number of bytes written to |buf| if it
4761+
* succeeds, or one of the following negative error codes:
47074762
*
47084763
* :enum:`NGHTTP2_ERR_NOMEM`
47094764
* Out of memory.
@@ -4734,8 +4789,8 @@ NGHTTP2_EXTERN ssize_t nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater,
47344789
*
47354790
* After this function returns, it is safe to delete the |nva|.
47364791
*
4737-
* This function returns 0 if it succeeds, or one of the following
4738-
* negative error codes:
4792+
* This function returns the number of bytes written to |vec| if it
4793+
* succeeds, or one of the following negative error codes:
47394794
*
47404795
* :enum:`NGHTTP2_ERR_NOMEM`
47414796
* Out of memory.

deps/nghttp2/lib/includes/nghttp2/nghttp2ver.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
* @macro
3030
* Version number of the nghttp2 library release
3131
*/
32-
#define NGHTTP2_VERSION "1.25.0"
32+
#define NGHTTP2_VERSION "1.29.0"
3333

3434
/**
3535
* @macro
3636
* Numerical representation of the version number of the nghttp2 library
3737
* release. This is a 24 bit number with 8 bits for major number, 8 bits
3838
* for minor and 8 bits for patch. Version 1.2.3 becomes 0x010203.
3939
*/
40-
#define NGHTTP2_VERSION_NUM 0x011900
40+
#define NGHTTP2_VERSION_NUM 0x011d00
4141

4242
#endif /* NGHTTP2VER_H */

deps/nghttp2/lib/nghttp2_buf.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ int nghttp2_bufs_advance(nghttp2_bufs *bufs);
398398
void nghttp2_bufs_seek_last_present(nghttp2_bufs *bufs);
399399

400400
/*
401-
* Returns nonzero if bufs->cur->next is not emtpy.
401+
* Returns nonzero if bufs->cur->next is not empty.
402402
*/
403403
int nghttp2_bufs_next_present(nghttp2_bufs *bufs);
404404

deps/nghttp2/lib/nghttp2_callbacks.c

+5
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,8 @@ void nghttp2_session_callbacks_set_error_callback(
168168
nghttp2_session_callbacks *cbs, nghttp2_error_callback error_callback) {
169169
cbs->error_callback = error_callback;
170170
}
171+
172+
void nghttp2_session_callbacks_set_error_callback2(
173+
nghttp2_session_callbacks *cbs, nghttp2_error_callback2 error_callback2) {
174+
cbs->error_callback2 = error_callback2;
175+
}

deps/nghttp2/lib/nghttp2_callbacks.h

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ struct nghttp2_session_callbacks {
119119
nghttp2_unpack_extension_callback unpack_extension_callback;
120120
nghttp2_on_extension_chunk_recv_callback on_extension_chunk_recv_callback;
121121
nghttp2_error_callback error_callback;
122+
nghttp2_error_callback2 error_callback2;
122123
};
123124

124125
#endif /* NGHTTP2_CALLBACKS_H */

deps/nghttp2/lib/nghttp2_frame.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@
7070
#define NGHTTP2_MAX_PADLEN 256
7171

7272
/* Union of extension frame payload */
73-
typedef union { nghttp2_ext_altsvc altsvc; } nghttp2_ext_frame_payload;
73+
typedef union {
74+
nghttp2_ext_altsvc altsvc;
75+
} nghttp2_ext_frame_payload;
7476

7577
void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd);
7678

deps/nghttp2/lib/nghttp2_hd.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ typedef struct {
211211

212212
#define HD_MAP_SIZE 128
213213

214-
typedef struct { nghttp2_hd_entry *table[HD_MAP_SIZE]; } nghttp2_hd_map;
214+
typedef struct {
215+
nghttp2_hd_entry *table[HD_MAP_SIZE];
216+
} nghttp2_hd_map;
215217

216218
struct nghttp2_hd_deflater {
217219
nghttp2_hd_context ctx;
@@ -313,7 +315,7 @@ void nghttp2_hd_deflate_free(nghttp2_hd_deflater *deflater);
313315
*
314316
* This function expands |bufs| as necessary to store the result. If
315317
* buffers is full and the process still requires more space, this
316-
* funtion fails and returns NGHTTP2_ERR_HEADER_COMP.
318+
* function fails and returns NGHTTP2_ERR_HEADER_COMP.
317319
*
318320
* After this function returns, it is safe to delete the |nva|.
319321
*

deps/nghttp2/lib/nghttp2_helper.c

+3
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ const char *nghttp2_strerror(int error_code) {
322322
return "Internal error";
323323
case NGHTTP2_ERR_CANCEL:
324324
return "Cancel";
325+
case NGHTTP2_ERR_SETTINGS_EXPECTED:
326+
return "When a local endpoint expects to receive SETTINGS frame, it "
327+
"receives an other type of frame";
325328
case NGHTTP2_ERR_NOMEM:
326329
return "Out of memory";
327330
case NGHTTP2_ERR_CALLBACK_FAILURE:

deps/nghttp2/lib/nghttp2_outbound_item.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ struct nghttp2_outbound_item {
112112
nghttp2_ext_frame_payload ext_frame_payload;
113113
nghttp2_aux_data aux_data;
114114
/* The priority used in priority comparion. Smaller is served
115-
ealier. For PING, SETTINGS and non-DATA frames (excluding
115+
earlier. For PING, SETTINGS and non-DATA frames (excluding
116116
response HEADERS frame) have dedicated cycle value defined above.
117117
For DATA frame, cycle is computed by taking into account of
118118
effective weight and frame payload length previously sent, so

deps/nghttp2/lib/nghttp2_pq.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@
3535

3636
/* Implementation of priority queue */
3737

38-
typedef struct { size_t index; } nghttp2_pq_entry;
38+
typedef struct {
39+
size_t index;
40+
} nghttp2_pq_entry;
3941

4042
typedef struct {
4143
/* The pointer to the pointer to the item stored */
@@ -71,7 +73,7 @@ void nghttp2_pq_free(nghttp2_pq *pq);
7173
/*
7274
* Adds |item| to the priority queue |pq|.
7375
*
74-
* This function returns 0 if it succeds, or one of the following
76+
* This function returns 0 if it succeeds, or one of the following
7577
* negative error codes:
7678
*
7779
* NGHTTP2_ERR_NOMEM

deps/nghttp2/lib/nghttp2_queue.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ typedef struct nghttp2_queue_cell {
3636
struct nghttp2_queue_cell *next;
3737
} nghttp2_queue_cell;
3838

39-
typedef struct { nghttp2_queue_cell *front, *back; } nghttp2_queue;
39+
typedef struct {
40+
nghttp2_queue_cell *front, *back;
41+
} nghttp2_queue;
4042

4143
void nghttp2_queue_init(nghttp2_queue *queue);
4244
void nghttp2_queue_free(nghttp2_queue *queue);

deps/nghttp2/lib/nghttp2_session.c

+28-23
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,16 @@ static int check_ext_type_set(const uint8_t *ext_types, uint8_t type) {
148148
}
149149

150150
static int session_call_error_callback(nghttp2_session *session,
151-
const char *fmt, ...) {
151+
int lib_error_code, const char *fmt,
152+
...) {
152153
size_t bufsize;
153154
va_list ap;
154155
char *buf;
155156
int rv;
156157
nghttp2_mem *mem;
157158

158-
if (!session->callbacks.error_callback) {
159+
if (!session->callbacks.error_callback &&
160+
!session->callbacks.error_callback2) {
159161
return 0;
160162
}
161163

@@ -189,8 +191,13 @@ static int session_call_error_callback(nghttp2_session *session,
189191
return 0;
190192
}
191193

192-
rv = session->callbacks.error_callback(session, buf, (size_t)rv,
193-
session->user_data);
194+
if (session->callbacks.error_callback2) {
195+
rv = session->callbacks.error_callback2(session, lib_error_code, buf,
196+
(size_t)rv, session->user_data);
197+
} else {
198+
rv = session->callbacks.error_callback(session, buf, (size_t)rv,
199+
session->user_data);
200+
}
194201

195202
nghttp2_mem_free(mem, buf);
196203

@@ -541,9 +548,8 @@ static int session_new(nghttp2_session **session_ptr,
541548
if (nghttp2_enable_strict_preface) {
542549
nghttp2_inbound_frame *iframe = &(*session_ptr)->iframe;
543550

544-
if (server &&
545-
((*session_ptr)->opt_flags & NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC) ==
546-
0) {
551+
if (server && ((*session_ptr)->opt_flags &
552+
NGHTTP2_OPTMASK_NO_RECV_CLIENT_MAGIC) == 0) {
547553
iframe->state = NGHTTP2_IB_READ_CLIENT_MAGIC;
548554
iframe->payloadleft = NGHTTP2_CLIENT_MAGIC_LEN;
549555
} else {
@@ -2183,7 +2189,7 @@ static int session_prep_frame(nghttp2_session *session,
21832189
closed. */
21842190
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
21852191

2186-
/* predicte should fail if stream is NULL. */
2192+
/* predicate should fail if stream is NULL. */
21872193
rv = session_predicate_push_promise_send(session, stream);
21882194
if (rv != 0) {
21892195
return rv;
@@ -2411,19 +2417,16 @@ static int session_close_stream_on_goaway(nghttp2_session *session,
24112417
nghttp2_stream *stream, *next_stream;
24122418
nghttp2_close_stream_on_goaway_arg arg = {session, NULL, last_stream_id,
24132419
incoming};
2414-
uint32_t error_code;
24152420

24162421
rv = nghttp2_map_each(&session->streams, find_stream_on_goaway_func, &arg);
24172422
assert(rv == 0);
24182423

2419-
error_code =
2420-
session->server && incoming ? NGHTTP2_REFUSED_STREAM : NGHTTP2_CANCEL;
2421-
24222424
stream = arg.head;
24232425
while (stream) {
24242426
next_stream = stream->closed_next;
24252427
stream->closed_next = NULL;
2426-
rv = nghttp2_session_close_stream(session, stream->stream_id, error_code);
2428+
rv = nghttp2_session_close_stream(session, stream->stream_id,
2429+
NGHTTP2_REFUSED_STREAM);
24272430

24282431
/* stream may be deleted here */
24292432

@@ -3608,7 +3611,7 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame,
36083611
nv.name->base, (int)nv.value->len, nv.value->base);
36093612

36103613
rv2 = session_call_error_callback(
3611-
session,
3614+
session, NGHTTP2_ERR_HTTP_HEADER,
36123615
"Ignoring received invalid HTTP header field: frame type: "
36133616
"%u, stream: %d, name: [%.*s], value: [%.*s]",
36143617
frame->hd.type, frame->hd.stream_id, (int)nv.name->len,
@@ -3626,8 +3629,9 @@ static int inflate_header_block(nghttp2_session *session, nghttp2_frame *frame,
36263629
nv.name->base, (int)nv.value->len, nv.value->base);
36273630

36283631
rv = session_call_error_callback(
3629-
session, "Invalid HTTP header field was received: frame type: "
3630-
"%u, stream: %d, name: [%.*s], value: [%.*s]",
3632+
session, NGHTTP2_ERR_HTTP_HEADER,
3633+
"Invalid HTTP header field was received: frame type: "
3634+
"%u, stream: %d, name: [%.*s], value: [%.*s]",
36313635
frame->hd.type, frame->hd.stream_id, (int)nv.name->len,
36323636
nv.name->base, (int)nv.value->len, nv.value->base);
36333637

@@ -3781,7 +3785,7 @@ int nghttp2_session_on_request_headers_received(nghttp2_session *session,
37813785
session, frame, NGHTTP2_ERR_PROTO, "request HEADERS: stream_id == 0");
37823786
}
37833787

3784-
/* If client recieves idle stream from server, it is invalid
3788+
/* If client receives idle stream from server, it is invalid
37853789
regardless stream ID is even or odd. This is because client is
37863790
not expected to receive request from server. */
37873791
if (!session->server) {
@@ -5345,9 +5349,10 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
53455349
iframe->state = NGHTTP2_IB_IGN_ALL;
53465350

53475351
rv = session_call_error_callback(
5348-
session, "Remote peer returned unexpected data while we expected "
5349-
"SETTINGS frame. Perhaps, peer does not support HTTP/2 "
5350-
"properly.");
5352+
session, NGHTTP2_ERR_SETTINGS_EXPECTED,
5353+
"Remote peer returned unexpected data while we expected "
5354+
"SETTINGS frame. Perhaps, peer does not support HTTP/2 "
5355+
"properly.");
53515356

53525357
if (nghttp2_is_fatal(rv)) {
53535358
return rv;
@@ -5588,13 +5593,13 @@ ssize_t nghttp2_session_mem_recv(nghttp2_session *session, const uint8_t *in,
55885593
if (iframe->payloadleft) {
55895594
nghttp2_settings_entry *min_header_table_size_entry;
55905595

5591-
/* We allocate iv with addtional one entry, to store the
5596+
/* We allocate iv with additional one entry, to store the
55925597
minimum header table size. */
55935598
iframe->max_niv =
55945599
iframe->frame.hd.length / NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH + 1;
55955600

5596-
iframe->iv = nghttp2_mem_malloc(
5597-
mem, sizeof(nghttp2_settings_entry) * iframe->max_niv);
5601+
iframe->iv = nghttp2_mem_malloc(mem, sizeof(nghttp2_settings_entry) *
5602+
iframe->max_niv);
55985603

55995604
if (!iframe->iv) {
56005605
return NGHTTP2_ERR_NOMEM;

0 commit comments

Comments
 (0)