Skip to content

Commit 5c2ee4e

Browse files
gengjiawenZYSzys
authored andcommitted
deps: update nghttp2 to 1.37.0
PR-URL: #26990 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
1 parent 198d7a4 commit 5c2ee4e

File tree

7 files changed

+43
-38
lines changed

7 files changed

+43
-38
lines changed

deps/nghttp2/lib/CMakeLists.txt

+15-10
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,23 @@ if(WIN32)
3838
endif()
3939

4040
# Public shared library
41-
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
42-
set_target_properties(nghttp2 PROPERTIES
43-
COMPILE_FLAGS "${WARNCFLAGS}"
44-
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
45-
C_VISIBILITY_PRESET hidden
46-
)
47-
target_include_directories(nghttp2 INTERFACE
41+
if(ENABLE_SHARED_LIB)
42+
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
43+
set_target_properties(nghttp2 PROPERTIES
44+
COMPILE_FLAGS "${WARNCFLAGS}"
45+
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
46+
C_VISIBILITY_PRESET hidden
47+
)
48+
target_include_directories(nghttp2 INTERFACE
4849
"${CMAKE_CURRENT_BINARY_DIR}/includes"
4950
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
50-
)
51+
)
52+
53+
install(TARGETS nghttp2
54+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
55+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
56+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
57+
endif()
5158

5259
if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
5360
# Static library (for unittests because of symbol visibility)
@@ -64,8 +71,6 @@ if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
6471
endif()
6572
endif()
6673

67-
install(TARGETS nghttp2
68-
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
6974

7075
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp2.pc"
7176
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
# define WIN32
3232
#endif
3333

34+
/* Compatibility for non-Clang compilers */
35+
#ifndef __has_declspec_attribute
36+
# define __has_declspec_attribute(x) 0
37+
#endif
38+
3439
#ifdef __cplusplus
3540
extern "C" {
3641
#endif
@@ -51,7 +56,8 @@ extern "C" {
5156

5257
#ifdef NGHTTP2_STATICLIB
5358
# define NGHTTP2_EXTERN
54-
#elif defined(WIN32)
59+
#elif defined(WIN32) || (__has_declspec_attribute(dllexport) && \
60+
__has_declspec_attribute(dllimport))
5561
# ifdef BUILDING_NGHTTP2
5662
# define NGHTTP2_EXTERN __declspec(dllexport)
5763
# else /* !BUILDING_NGHTTP2 */

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.34.0"
32+
#define NGHTTP2_VERSION "1.37.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 0x012200
40+
#define NGHTTP2_VERSION_NUM 0x012500
4141

4242
#endif /* NGHTTP2VER_H */

deps/nghttp2/lib/nghttp2_hd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
13901390
if (indexing_mode == NGHTTP2_HD_WITH_INDEXING) {
13911391
nghttp2_hd_nv hd_nv;
13921392

1393-
if (idx != -1 && idx < (ssize_t)NGHTTP2_STATIC_TABLE_LENGTH) {
1393+
if (idx != -1) {
13941394
hd_nv.name = nghttp2_hd_table_get(&deflater->ctx, (size_t)idx).name;
13951395
nghttp2_rcbuf_incref(hd_nv.name);
13961396
} else {

deps/nghttp2/lib/nghttp2_session.h

-3
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,6 @@ struct nghttp2_session {
209209
nghttp2_session_callbacks callbacks;
210210
/* Memory allocator */
211211
nghttp2_mem mem;
212-
/* Base value when we schedule next DATA frame write. This is
213-
updated when one frame was written. */
214-
uint64_t last_cycle;
215212
void *user_data;
216213
/* Points to the latest incoming closed stream. NULL if there is no
217214
closed stream. Only used when session is initialized as

deps/nghttp2/lib/nghttp2_stream.c

+16-19
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "nghttp2_session.h"
3131
#include "nghttp2_helper.h"
3232
#include "nghttp2_debug.h"
33+
#include "nghttp2_frame.h"
3334

3435
/* Maximum distance between any two stream's cycle in the same
3536
prirority queue. Imagine stream A's cycle is A, and stream B's
@@ -40,7 +41,8 @@
4041
words, B is really greater than or equal to A. Otherwise, A is a
4142
result of overflow, and it is actually A > B if we consider that
4243
fact. */
43-
#define NGHTTP2_MAX_CYCLE_DISTANCE (16384 * 256 + 255)
44+
#define NGHTTP2_MAX_CYCLE_DISTANCE \
45+
((uint64_t)NGHTTP2_MAX_FRAME_SIZE_MAX * 256 + 255)
4446

4547
static int stream_less(const void *lhsx, const void *rhsx) {
4648
const nghttp2_stream *lhs, *rhs;
@@ -52,11 +54,7 @@ static int stream_less(const void *lhsx, const void *rhsx) {
5254
return lhs->seq < rhs->seq;
5355
}
5456

55-
if (lhs->cycle < rhs->cycle) {
56-
return rhs->cycle - lhs->cycle <= NGHTTP2_MAX_CYCLE_DISTANCE;
57-
}
58-
59-
return lhs->cycle - rhs->cycle > NGHTTP2_MAX_CYCLE_DISTANCE;
57+
return rhs->cycle - lhs->cycle <= NGHTTP2_MAX_CYCLE_DISTANCE;
6058
}
6159

6260
void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
@@ -135,14 +133,14 @@ static int stream_subtree_active(nghttp2_stream *stream) {
135133
/*
136134
* Returns next cycle for |stream|.
137135
*/
138-
static void stream_next_cycle(nghttp2_stream *stream, uint32_t last_cycle) {
139-
uint32_t penalty;
136+
static void stream_next_cycle(nghttp2_stream *stream, uint64_t last_cycle) {
137+
uint64_t penalty;
140138

141-
penalty = (uint32_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT +
139+
penalty = (uint64_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT +
142140
stream->pending_penalty;
143141

144142
stream->cycle = last_cycle + penalty / (uint32_t)stream->weight;
145-
stream->pending_penalty = penalty % (uint32_t)stream->weight;
143+
stream->pending_penalty = (uint32_t)(penalty % (uint32_t)stream->weight);
146144
}
147145

148146
static int stream_obq_push(nghttp2_stream *dep_stream, nghttp2_stream *stream) {
@@ -153,7 +151,7 @@ static int stream_obq_push(nghttp2_stream *dep_stream, nghttp2_stream *stream) {
153151
stream_next_cycle(stream, dep_stream->descendant_last_cycle);
154152
stream->seq = dep_stream->descendant_next_seq++;
155153

156-
DEBUGF("stream: stream=%d obq push cycle=%d\n", stream->stream_id,
154+
DEBUGF("stream: stream=%d obq push cycle=%lu\n", stream->stream_id,
157155
stream->cycle);
158156

159157
DEBUGF("stream: push stream %d to stream %d\n", stream->stream_id,
@@ -239,7 +237,7 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) {
239237

240238
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
241239

242-
DEBUGF("stream: stream=%d obq resched cycle=%d\n", stream->stream_id,
240+
DEBUGF("stream: stream=%d obq resched cycle=%lu\n", stream->stream_id,
243241
stream->cycle);
244242

245243
dep_stream->last_writelen = stream->last_writelen;
@@ -248,9 +246,9 @@ void nghttp2_stream_reschedule(nghttp2_stream *stream) {
248246

249247
void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
250248
nghttp2_stream *dep_stream;
251-
uint32_t last_cycle;
249+
uint64_t last_cycle;
252250
int32_t old_weight;
253-
uint32_t wlen_penalty;
251+
uint64_t wlen_penalty;
254252

255253
if (stream->weight == weight) {
256254
return;
@@ -273,7 +271,7 @@ void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
273271

274272
nghttp2_pq_remove(&dep_stream->obq, &stream->pq_entry);
275273

276-
wlen_penalty = (uint32_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT;
274+
wlen_penalty = (uint64_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT;
277275

278276
/* Compute old stream->pending_penalty we used to calculate
279277
stream->cycle */
@@ -289,17 +287,16 @@ void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
289287
place */
290288
stream_next_cycle(stream, last_cycle);
291289

292-
if (stream->cycle < dep_stream->descendant_last_cycle &&
293-
(dep_stream->descendant_last_cycle - stream->cycle) <=
294-
NGHTTP2_MAX_CYCLE_DISTANCE) {
290+
if (dep_stream->descendant_last_cycle - stream->cycle <=
291+
NGHTTP2_MAX_CYCLE_DISTANCE) {
295292
stream->cycle = dep_stream->descendant_last_cycle;
296293
}
297294

298295
/* Continue to use same stream->seq */
299296

300297
nghttp2_pq_push(&dep_stream->obq, &stream->pq_entry);
301298

302-
DEBUGF("stream: stream=%d obq resched cycle=%d\n", stream->stream_id,
299+
DEBUGF("stream: stream=%d obq resched cycle=%lu\n", stream->stream_id,
303300
stream->cycle);
304301
}
305302

deps/nghttp2/lib/nghttp2_stream.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ struct nghttp2_stream {
148148
/* Received body so far */
149149
int64_t recv_content_length;
150150
/* Base last_cycle for direct descendent streams. */
151-
uint32_t descendant_last_cycle;
151+
uint64_t descendant_last_cycle;
152152
/* Next scheduled time to sent item */
153-
uint32_t cycle;
153+
uint64_t cycle;
154154
/* Next seq used for direct descendant streams */
155155
uint64_t descendant_next_seq;
156156
/* Secondary key for prioritization to break a tie for cycle. This

0 commit comments

Comments
 (0)