summary refs log tree commit diff
path: root/pkgs/tools/networking/curl
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2016-11-23 16:27:56 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2016-11-26 14:48:05 +0100
commit9007303001dc885e8424540ee28f89abac5c5bab (patch)
tree17d39304115ec8e29a15c8327c352edb1fd9de53 /pkgs/tools/networking/curl
parent94fe387fcb3b77839490010ca05dd5d274a3a567 (diff)
downloadnixlib-9007303001dc885e8424540ee28f89abac5c5bab.tar
nixlib-9007303001dc885e8424540ee28f89abac5c5bab.tar.gz
nixlib-9007303001dc885e8424540ee28f89abac5c5bab.tar.bz2
nixlib-9007303001dc885e8424540ee28f89abac5c5bab.tar.lz
nixlib-9007303001dc885e8424540ee28f89abac5c5bab.tar.xz
nixlib-9007303001dc885e8424540ee28f89abac5c5bab.tar.zst
nixlib-9007303001dc885e8424540ee28f89abac5c5bab.zip
curl: add upstream patch to fix HTTP2 performance issues
See #20639. Patch has to be in nixpkgs because fetchurl depends on curl.
Diffstat (limited to 'pkgs/tools/networking/curl')
-rw-r--r--pkgs/tools/networking/curl/default.nix2
-rw-r--r--pkgs/tools/networking/curl/disable-ca-install.patch14
-rw-r--r--pkgs/tools/networking/curl/fix-http2-window-size.patch88
3 files changed, 90 insertions, 14 deletions
diff --git a/pkgs/tools/networking/curl/default.nix b/pkgs/tools/networking/curl/default.nix
index 56c0d26a999a..5dd523d6fa6b 100644
--- a/pkgs/tools/networking/curl/default.nix
+++ b/pkgs/tools/networking/curl/default.nix
@@ -42,6 +42,8 @@ stdenv.mkDerivation rec {
     optional sslSupport openssl ++
     optional scpSupport libssh2;
 
+  patches = stdenv.lib.optional http2Support ./fix-http2-window-size.patch;
+
   # for the second line see http://curl.haxx.se/mail/tracker-2014-03/0087.html
   preConfigure = ''
     sed -e 's|/usr/bin|/no-such-path|g' -i.bak configure
diff --git a/pkgs/tools/networking/curl/disable-ca-install.patch b/pkgs/tools/networking/curl/disable-ca-install.patch
deleted file mode 100644
index aedf8ef5c3e2..000000000000
--- a/pkgs/tools/networking/curl/disable-ca-install.patch
+++ /dev/null
@@ -1,14 +0,0 @@
---- a/lib/Makefile.in
-+++ b/lib/Makefile.in
-@@ -106,10 +106,7 @@ else
- endif
- 
- install-data-hook:
--	@if test -n "@CURL_CA_BUNDLE@"; then \
--	  $(mkinstalldirs) `dirname $(DESTDIR)@CURL_CA_BUNDLE@`; \
--	  @INSTALL_DATA@ $(srcdir)/ca-bundle.crt $(DESTDIR)@CURL_CA_BUNDLE@; \
--        fi
-+	echo "install-data-hook disabled"
- 
- # this hook is mainly for non-unix systems to build even if configure
- # isn't run
diff --git a/pkgs/tools/networking/curl/fix-http2-window-size.patch b/pkgs/tools/networking/curl/fix-http2-window-size.patch
new file mode 100644
index 000000000000..6fac3e1b42ac
--- /dev/null
+++ b/pkgs/tools/networking/curl/fix-http2-window-size.patch
@@ -0,0 +1,88 @@
+From a4d888857ede39a8e2aa5f961048c6362d3a5377 Mon Sep 17 00:00:00 2001
+From: Jay Satiro <raysatiro@yahoo.com>
+Date: Wed, 16 Nov 2016 02:55:30 -0500
+Subject: [PATCH] http2: Use huge HTTP/2 windows
+
+- Improve performance by using a huge HTTP/2 window size.
+
+Bug: https://github.com/curl/curl/issues/1102
+Reported-by: afrind@users.noreply.github.com
+Assisted-by: Tatsuhiro Tsujikawa
+---
+ docs/TODO   |  8 --------
+ lib/http2.c | 15 +++++++++++++--
+ 2 files changed, 13 insertions(+), 10 deletions(-)
+
+diff --git a/docs/TODO b/docs/TODO
+index c3bc4eb..99c610f 100644
+--- a/docs/TODO
++++ b/docs/TODO
+@@ -63,7 +63,6 @@
+  5.1 Better persistency for HTTP 1.0
+  5.2 support FF3 sqlite cookie files
+  5.3 Rearrange request header order
+- 5.4 Use huge HTTP/2 windows
+  5.5 auth= in URLs
+  5.6 Refuse "downgrade" redirects
+  5.7 Brotli compression
+@@ -528,13 +527,6 @@ This is not detailed in any FTP specification.
+  headers use a default value so only headers that need to be moved have to be
+  specified.
+ 
+-5.4 Use huge HTTP/2 windows
+-
+- We're currently using nghttp2's default window size which is terribly small
+- (64K). This becomes a bottle neck over high bandwidth networks. We should
+- instead make the window size to be very big (512MB?) as we really don't do
+- much flow control anyway.
+-
+ 5.5 auth= in URLs
+ 
+  Add the ability to specify the preferred authentication mechanism to use by
+diff --git a/lib/http2.c b/lib/http2.c
+index 6720984..202ab1b 100644
+--- a/lib/http2.c
++++ b/lib/http2.c
+@@ -59,6 +59,8 @@
+ #define nghttp2_session_callbacks_set_error_callback(x,y)
+ #endif
+ 
++#define HTTP2_HUGE_WINDOW_SIZE (1 << 30)
++
+ /*
+  * Curl_http2_init_state() is called when the easy handle is created and
+  * allows for HTTP/2 specific init of state.
+@@ -965,7 +967,7 @@ static ssize_t data_source_read_callback(nghttp2_session *session,
+  */
+ static nghttp2_settings_entry settings[] = {
+   { NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 100 },
+-  { NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, NGHTTP2_INITIAL_WINDOW_SIZE },
++  { NGHTTP2_SETTINGS_INITIAL_WINDOW_SIZE, HTTP2_HUGE_WINDOW_SIZE },
+ };
+ 
+ #define H2_BUFSIZE 32768
+@@ -2031,7 +2033,8 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
+   else {
+     /* stream ID is unknown at this point */
+     stream->stream_id = -1;
+-    rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE, NULL, 0);
++    rv = nghttp2_submit_settings(httpc->h2, NGHTTP2_FLAG_NONE, settings,
++                                 sizeof(settings) / sizeof(settings[0]));
+     if(rv != 0) {
+       failf(data, "nghttp2_submit_settings() failed: %s(%d)",
+             nghttp2_strerror(rv), rv);
+@@ -2039,6 +2042,14 @@ CURLcode Curl_http2_switched(struct connectdata *conn,
+     }
+   }
+ 
++  rv = nghttp2_session_set_local_window_size(httpc->h2, NGHTTP2_FLAG_NONE, 0,
++                                             HTTP2_HUGE_WINDOW_SIZE);
++  if(rv != 0) {
++    failf(data, "nghttp2_session_set_local_window_size() failed: %s(%d)",
++          nghttp2_strerror(rv), rv);
++    return CURLE_HTTP2;
++  }
++
+   /* we are going to copy mem to httpc->inbuf.  This is required since
+      mem is part of buffer pointed by stream->mem, and callbacks
+      called by nghttp2_session_mem_recv() will write stream specific