Meta: Patch nghttp2 to ignore DATA frames after a stream is half-closed

Otherwise, stopping downloads repeatedly will result in the reused
connection to the server being closed by nghttp2 with a GOAWAY frame
with a code of 0xB (ENHANCE_YOUR_CALM).

For more information: https://github.com/nghttp2/nghttp2/issues/2597
This commit is contained in:
Zaggy1024 2026-01-14 16:40:09 -06:00 committed by Gregory Bertilson
parent b37f42a887
commit 0734a37e24
5 changed files with 95 additions and 0 deletions

View file

@ -0,0 +1,20 @@
diff --git a/lib/nghttp2_session.c b/lib/nghttp2_session.c
index 518296e777..680cc1805c 100644
--- a/lib/nghttp2_session.c
+++ b/lib/nghttp2_session.c
@@ -5489,15 +5489,6 @@ nghttp2_ssize nghttp2_session_mem_recv2(nghttp2_session *session,
DEBUGF("recv: DATA not allowed stream_id=%d\n",
iframe->frame.hd.stream_id);
- rv = session_update_glitch_ratelim(session);
- if (rv != 0) {
- return rv;
- }
-
- if (iframe->state == NGHTTP2_IB_IGN_ALL) {
- return (nghttp2_ssize)inlen;
- }
-
iframe->state = NGHTTP2_IB_IGN_DATA;
break;
}

View file

@ -0,0 +1,56 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO nghttp2/nghttp2
REF "v${VERSION}"
SHA512 95af9926dfd2454dff52ea4ba2b6708548a9add0f48e14d3d843982609168d79dabf2958076e5761fac6d00c5b1f4d0fe5d9d1694c1e07c92a4ce3cdf0023ef6
HEAD_REF master
PATCHES
allow-data-after-half-closed.patch
)
string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" ENABLE_STATIC_CRT)
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" ENABLE_STATIC_LIB)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DENABLE_LIB_ONLY=ON
-DENABLE_DOC=OFF
-DBUILD_TESTING=OFF
"-DENABLE_STATIC_CRT=${ENABLE_STATIC_CRT}"
"-DBUILD_STATIC_LIBS=${ENABLE_STATIC_LIB}"
-DCMAKE_DISABLE_FIND_PACKAGE_Python3=ON
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Libngtcp2=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Libngtcp2_crypto_quictls=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Libnghttp3=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Systemd=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Jansson=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Libevent=ON
-DCMAKE_DISABLE_FIND_PACKAGE_LibXml2=ON
-DCMAKE_DISABLE_FIND_PACKAGE_Jemalloc=ON
MAYBE_UNUSED_VARIABLES
CMAKE_DISABLE_FIND_PACKAGE_Libngtcp2_crypto_quictls
ENABLE_STATIC_CRT
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/share/doc"
"${CURRENT_PACKAGES_DIR}/debug/lib/cmake"
"${CURRENT_PACKAGES_DIR}/lib/cmake"
)
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(APPEND "${CURRENT_PACKAGES_DIR}/include/nghttp2/nghttp2ver.h" [[
#ifndef NGHTTP2_STATICLIB
# define NGHTTP2_STATICLIB
#endif
]])
endif()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")

View file

@ -0,0 +1,14 @@
{
"name": "nghttp2",
"version": "1.68.0",
"port-version": 1,
"description": "Implementation of the Hypertext Transfer Protocol version 2 in C",
"homepage": "https://github.com/nghttp2/nghttp2",
"license": "MIT",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View file

@ -40,6 +40,7 @@ flatpak_runtime_libs = [
"harfbuzz",
"libjpeg-turbo",
"libproxy",
"nghttp2", # FIXME: This can be removed when the vcpkg overlay is no longer needed.
"qtbase",
"qtmultimedia",
"sqlite3",

View file

@ -300,6 +300,10 @@
"name": "mman",
"version": "git-f5ff813#5"
},
{
"name": "nghttp2",
"version": "1.68.0#1"
},
{
"name": "openssl",
"version": "3.5.3#0"