!278 tool_cb_rea: limit rate unpause for -T . uploads

From: @baiguoguo 
Reviewed-by: @zengwefeng 
Signed-off-by: @zengwefeng
This commit is contained in:
openeuler-ci-bot 2024-05-23 03:36:04 +00:00 committed by Gitee
commit 322b260942
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 67 additions and 1 deletions

View File

@ -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

View File

@ -6,7 +6,7 @@
Name: curl Name: curl
Version: 8.4.0 Version: 8.4.0
Release: 2 Release: 3
Summary: Curl is used in command lines or scripts to transfer data Summary: Curl is used in command lines or scripts to transfer data
License: curl License: curl
URL: https://curl.se/ URL: https://curl.se/
@ -22,6 +22,8 @@ Patch15: backport-openssl-avoid-BN_num_bits-NULL-pointer-derefs.patch
Patch16: backport-pre-CVE-2024-2004.patch Patch16: backport-pre-CVE-2024-2004.patch
Patch17: backport-CVE-2024-2004.patch Patch17: backport-CVE-2024-2004.patch
Patch18: backport-CVE-2024-2398.patch Patch18: backport-CVE-2024-2398.patch
Patch19: backport-tool_cb_rea-limit-rate-unpause-for-T-uploads.patch
#https://github.com/curl/curl/pull/13506
BuildRequires: automake brotli-devel coreutils gcc groff krb5-devel BuildRequires: automake brotli-devel coreutils gcc groff krb5-devel
BuildRequires: libidn2-devel libnghttp2-devel libpsl-devel BuildRequires: libidn2-devel libnghttp2-devel libpsl-devel
@ -206,6 +208,9 @@ rm -rf ${RPM_BUILD_ROOT}%{_libdir}/libcurl.la
%{_mandir}/man3/* %{_mandir}/man3/*
%changelog %changelog
* Thu May 09 2024 baiguo <baiguo@kylinos.cn> - 8.4.0-3
- DESC: tool_cb_rea: limit rate unpause for -T . uploads
* Mon Apr 01 2024 zhouyihang <zhouyihang3@h-partners.com> - 8.4.0-2 * Mon Apr 01 2024 zhouyihang <zhouyihang3@h-partners.com> - 8.4.0-2
- Type:CVE - Type:CVE
- CVE:CVE-2024-2004 CVE-2024-2398 - CVE:CVE-2024-2004 CVE-2024-2398