From 0734a37e24b0627ccda54b70b1611a17b74b79fc Mon Sep 17 00:00:00 2001 From: Zaggy1024 Date: Wed, 14 Jan 2026 16:40:09 -0600 Subject: [PATCH] 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 --- .../allow-data-after-half-closed.patch | 20 +++++++ .../overlay-ports/nghttp2/portfile.cmake | 56 +++++++++++++++++++ .../vcpkg/overlay-ports/nghttp2/vcpkg.json | 14 +++++ Meta/check-flatpak.py | 1 + vcpkg.json | 4 ++ 5 files changed, 95 insertions(+) create mode 100644 Meta/CMake/vcpkg/overlay-ports/nghttp2/allow-data-after-half-closed.patch create mode 100644 Meta/CMake/vcpkg/overlay-ports/nghttp2/portfile.cmake create mode 100644 Meta/CMake/vcpkg/overlay-ports/nghttp2/vcpkg.json diff --git a/Meta/CMake/vcpkg/overlay-ports/nghttp2/allow-data-after-half-closed.patch b/Meta/CMake/vcpkg/overlay-ports/nghttp2/allow-data-after-half-closed.patch new file mode 100644 index 0000000000..e061a1f943 --- /dev/null +++ b/Meta/CMake/vcpkg/overlay-ports/nghttp2/allow-data-after-half-closed.patch @@ -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; + } diff --git a/Meta/CMake/vcpkg/overlay-ports/nghttp2/portfile.cmake b/Meta/CMake/vcpkg/overlay-ports/nghttp2/portfile.cmake new file mode 100644 index 0000000000..a01ecad7d5 --- /dev/null +++ b/Meta/CMake/vcpkg/overlay-ports/nghttp2/portfile.cmake @@ -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") diff --git a/Meta/CMake/vcpkg/overlay-ports/nghttp2/vcpkg.json b/Meta/CMake/vcpkg/overlay-ports/nghttp2/vcpkg.json new file mode 100644 index 0000000000..4db23172ca --- /dev/null +++ b/Meta/CMake/vcpkg/overlay-ports/nghttp2/vcpkg.json @@ -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 + } + ] +} diff --git a/Meta/check-flatpak.py b/Meta/check-flatpak.py index a999346c55..906278bc15 100755 --- a/Meta/check-flatpak.py +++ b/Meta/check-flatpak.py @@ -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", diff --git a/vcpkg.json b/vcpkg.json index d110ca0a11..6a57de4431 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -300,6 +300,10 @@ "name": "mman", "version": "git-f5ff813#5" }, + { + "name": "nghttp2", + "version": "1.68.0#1" + }, { "name": "openssl", "version": "3.5.3#0"