summaryrefslogtreecommitdiff
path: root/backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2025-03-04 03:28:50 +0000
committerCoprDistGit <infra@openeuler.org>2025-03-04 03:28:50 +0000
commit510937df92473c5a6830d87f078386db8dbf896d (patch)
tree64d9befb90cb19890926aedd71df1a7a5452e08c /backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch
parentdbf64f99d0f0a31203092f9afdc6c07e13917313 (diff)
automatic import of curlopeneuler24.03_LTS_SP1
Diffstat (limited to 'backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch')
-rw-r--r--backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch61
1 files changed, 61 insertions, 0 deletions
diff --git a/backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch b/backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch
new file mode 100644
index 0000000..fd98749
--- /dev/null
+++ b/backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch
@@ -0,0 +1,61 @@
+From 5f4aaf8b66ef04208c1c2121d4b780c792303f32 Mon Sep 17 00:00:00 2001
+From: Daniel Stenberg <daniel@haxx.se>
+Date: Tue, 30 Apr 2024 11:07:28 +0200
+Subject: [PATCH] tool_cb_rea: limit rate unpause for -T . uploads
+Reference:https://github.com/curl/curl/pull/13506
+
+---
+ src/tool_cb_rea.c | 30 ++++++++++++++++++++++++++++--
+ 1 file changed, 28 insertions(+), 2 deletions(-)
+
+diff --git a/src/tool_cb_rea.c b/src/tool_cb_rea.c
+index d70a9b9..f510f81 100644
+--- a/src/tool_cb_rea.c
++++ b/src/tool_cb_rea.c
+@@ -36,6 +36,7 @@
+ #include "tool_operate.h"
+ #include "tool_util.h"
+ #include "tool_msgs.h"
++#include "tool_sleep.h"
+
+ #include "memdebug.h" /* keep this as LAST include */
+
+@@ -124,8 +125,33 @@ int tool_readbusy_cb(void *clientp,
+ (void)ulnow; /* unused */
+
+ if(config->readbusy) {
+- config->readbusy = FALSE;
+- curl_easy_pause(per->curl, CURLPAUSE_CONT);
++ /* lame code to keep the rate down because the input might not deliver
++ anything, get paused again and come back here immediately */
++ static long rate = 500;
++ static struct timeval prev;
++ static curl_off_t ulprev;
++
++ if(ulprev == ulnow) {
++ /* it did not upload anything since last call */
++ struct timeval now = tvnow();
++ if(prev.tv_sec)
++ /* get a rolling average rate */
++ /* rate = rate - rate/4 + tvdiff(now, prev)/4; */
++ rate -= rate/4 - tvdiff(now, prev)/4;
++ prev = now;
++ }
++ else {
++ rate = 50;
++ ulprev = ulnow;
++ }
++ if(rate >= 50) {
++ /* keeps the looping down to 20 times per second in the crazy case */
++ config->readbusy = FALSE;
++ curl_easy_pause(per->curl, CURLPAUSE_CONT);
++ }
++ else
++ /* sleep half a period */
++ tool_go_sleep(25);
+ }
+
+ return per->noprogress? 0 : CURL_PROGRESSFUNC_CONTINUE;
+--
+2.27.0
+