mirror of
https://github.com/curl/curl.git
synced 2026-06-18 08:55:39 +03:00
ratelimits: use minimal burst rate
Some protocols (and servers) prefer to batch IO and will not send data unless the window is of sufficient size. Set the burst rate for our rate limits to a minimum of 32KB to prevent stalling. Reported-by: Tatsuhiro Tsujikawa Closes #22016
This commit is contained in:
parent
f497b25672
commit
eb6d1e098e
2 changed files with 11 additions and 5 deletions
|
|
@ -141,12 +141,14 @@ static void rlimit_tune_steps(struct Curl_rlimit *r,
|
|||
r->step_us = CURL_US_PER_SEC + ((timediff_t)mstep_inc * 1000);
|
||||
r->rate_per_step += rate_inc;
|
||||
r->tokens = r->rate_per_step;
|
||||
if(r->burst_per_step) {
|
||||
curl_off_t burst_inc = ((r->burst_per_step * mstep_inc) / 1000);
|
||||
if(burst_inc)
|
||||
r->burst_per_step += burst_inc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(r->burst_per_step)
|
||||
r->burst_per_step = r->rate_per_step;
|
||||
}
|
||||
|
||||
void Curl_rlimit_init(struct Curl_rlimit *r,
|
||||
|
|
|
|||
|
|
@ -2768,7 +2768,9 @@ static CURLcode setopt_offt(struct Curl_easy *data, CURLoption option,
|
|||
if(offt < 0)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
s->max_send_speed = offt;
|
||||
Curl_rlimit_init(&data->progress.ul.rlimit, offt, offt,
|
||||
/* use minimal burst rate of 32k. some protocol batch IO */
|
||||
Curl_rlimit_init(&data->progress.ul.rlimit, offt,
|
||||
CURLMAX(offt, (32 * 1024)),
|
||||
Curl_pgrs_now(data));
|
||||
break;
|
||||
case CURLOPT_MAX_RECV_SPEED_LARGE:
|
||||
|
|
@ -2779,7 +2781,9 @@ static CURLcode setopt_offt(struct Curl_easy *data, CURLoption option,
|
|||
if(offt < 0)
|
||||
return CURLE_BAD_FUNCTION_ARGUMENT;
|
||||
s->max_recv_speed = offt;
|
||||
Curl_rlimit_init(&data->progress.dl.rlimit, offt, offt,
|
||||
/* use minimal burst rate of 32k. some protocol batch IO */
|
||||
Curl_rlimit_init(&data->progress.dl.rlimit, offt,
|
||||
CURLMAX(offt, (32 * 1024)),
|
||||
Curl_pgrs_now(data));
|
||||
break;
|
||||
case CURLOPT_RESUME_FROM_LARGE:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue