Skip to content

Commit

Permalink
deps: update nghttp2 to 1.37.0
Browse files Browse the repository at this point in the history
Backport-PR-URL: #29123
PR-URL: #26990
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
gengjiawen authored and BethGriggs committed Aug 15, 2019
1 parent a0a14c8 commit ab0f2ac
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 38 deletions.
25 changes: 15 additions & 10 deletions deps/nghttp2/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,23 @@ if(WIN32)
endif()

# Public shared library
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
set_target_properties(nghttp2 PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
C_VISIBILITY_PRESET hidden
)
target_include_directories(nghttp2 INTERFACE
if(ENABLE_SHARED_LIB)
add_library(nghttp2 SHARED ${NGHTTP2_SOURCES} ${NGHTTP2_RES})
set_target_properties(nghttp2 PROPERTIES
COMPILE_FLAGS "${WARNCFLAGS}"
VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
C_VISIBILITY_PRESET hidden
)
target_include_directories(nghttp2 INTERFACE
"${CMAKE_CURRENT_BINARY_DIR}/includes"
"${CMAKE_CURRENT_SOURCE_DIR}/includes"
)
)

install(TARGETS nghttp2
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()

if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
# Static library (for unittests because of symbol visibility)
Expand All @@ -64,8 +71,6 @@ if(HAVE_CUNIT OR ENABLE_STATIC_LIB)
endif()
endif()

install(TARGETS nghttp2
DESTINATION "${CMAKE_INSTALL_LIBDIR}")

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libnghttp2.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
8 changes: 7 additions & 1 deletion deps/nghttp2/lib/includes/nghttp2/nghttp2.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
# define WIN32
#endif

/* Compatibility for non-Clang compilers */
#ifndef __has_declspec_attribute
# define __has_declspec_attribute(x) 0
#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -51,7 +56,8 @@ extern "C" {

#ifdef NGHTTP2_STATICLIB
# define NGHTTP2_EXTERN
#elif defined(WIN32)
#elif defined(WIN32) || (__has_declspec_attribute(dllexport) && \
__has_declspec_attribute(dllimport))
# ifdef BUILDING_NGHTTP2
# define NGHTTP2_EXTERN __declspec(dllexport)
# else /* !BUILDING_NGHTTP2 */
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.34.0"
#define NGHTTP2_VERSION "1.37.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 0x012200
#define NGHTTP2_VERSION_NUM 0x012500

#endif /* NGHTTP2VER_H */
2 changes: 1 addition & 1 deletion deps/nghttp2/lib/nghttp2_hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ static int deflate_nv(nghttp2_hd_deflater *deflater, nghttp2_bufs *bufs,
if (indexing_mode == NGHTTP2_HD_WITH_INDEXING) {
nghttp2_hd_nv hd_nv;

if (idx != -1 && idx < (ssize_t)NGHTTP2_STATIC_TABLE_LENGTH) {
if (idx != -1) {
hd_nv.name = nghttp2_hd_table_get(&deflater->ctx, (size_t)idx).name;
nghttp2_rcbuf_incref(hd_nv.name);
} else {
Expand Down
3 changes: 0 additions & 3 deletions deps/nghttp2/lib/nghttp2_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ struct nghttp2_session {
nghttp2_session_callbacks callbacks;
/* Memory allocator */
nghttp2_mem mem;
/* Base value when we schedule next DATA frame write. This is
updated when one frame was written. */
uint64_t last_cycle;
void *user_data;
/* Points to the latest incoming closed stream. NULL if there is no
closed stream. Only used when session is initialized as
Expand Down
35 changes: 16 additions & 19 deletions deps/nghttp2/lib/nghttp2_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "nghttp2_session.h"
#include "nghttp2_helper.h"
#include "nghttp2_debug.h"
#include "nghttp2_frame.h"

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

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

if (lhs->cycle < rhs->cycle) {
return rhs->cycle - lhs->cycle <= NGHTTP2_MAX_CYCLE_DISTANCE;
}

return lhs->cycle - rhs->cycle > NGHTTP2_MAX_CYCLE_DISTANCE;
return rhs->cycle - lhs->cycle <= NGHTTP2_MAX_CYCLE_DISTANCE;
}

void nghttp2_stream_init(nghttp2_stream *stream, int32_t stream_id,
Expand Down Expand Up @@ -135,14 +133,14 @@ static int stream_subtree_active(nghttp2_stream *stream) {
/*
* Returns next cycle for |stream|.
*/
static void stream_next_cycle(nghttp2_stream *stream, uint32_t last_cycle) {
uint32_t penalty;
static void stream_next_cycle(nghttp2_stream *stream, uint64_t last_cycle) {
uint64_t penalty;

penalty = (uint32_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT +
penalty = (uint64_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT +
stream->pending_penalty;

stream->cycle = last_cycle + penalty / (uint32_t)stream->weight;
stream->pending_penalty = penalty % (uint32_t)stream->weight;
stream->pending_penalty = (uint32_t)(penalty % (uint32_t)stream->weight);
}

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

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

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

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

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

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

void nghttp2_stream_change_weight(nghttp2_stream *stream, int32_t weight) {
nghttp2_stream *dep_stream;
uint32_t last_cycle;
uint64_t last_cycle;
int32_t old_weight;
uint32_t wlen_penalty;
uint64_t wlen_penalty;

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

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

wlen_penalty = (uint32_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT;
wlen_penalty = (uint64_t)stream->last_writelen * NGHTTP2_MAX_WEIGHT;

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

if (stream->cycle < dep_stream->descendant_last_cycle &&
(dep_stream->descendant_last_cycle - stream->cycle) <=
NGHTTP2_MAX_CYCLE_DISTANCE) {
if (dep_stream->descendant_last_cycle - stream->cycle <=
NGHTTP2_MAX_CYCLE_DISTANCE) {
stream->cycle = dep_stream->descendant_last_cycle;
}

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

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

DEBUGF("stream: stream=%d obq resched cycle=%d\n", stream->stream_id,
DEBUGF("stream: stream=%d obq resched cycle=%lu\n", stream->stream_id,
stream->cycle);
}

Expand Down
4 changes: 2 additions & 2 deletions deps/nghttp2/lib/nghttp2_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ struct nghttp2_stream {
/* Received body so far */
int64_t recv_content_length;
/* Base last_cycle for direct descendent streams. */
uint32_t descendant_last_cycle;
uint64_t descendant_last_cycle;
/* Next scheduled time to sent item */
uint32_t cycle;
uint64_t cycle;
/* Next seq used for direct descendant streams */
uint64_t descendant_next_seq;
/* Secondary key for prioritization to break a tie for cycle. This
Expand Down

0 comments on commit ab0f2ac

Please sign in to comment.