diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-03-26 13:08:44 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-03-27 12:38:28 +0100 |
commit | b5726e5549a45671391e88e45b9e0702ff4e7a28 (patch) | |
tree | e7f22eae0b8883c45ad7572ab621e7b85c7ff6f1 /lib | |
parent | 24e469f6d61635f85bd4a0845c07aef0c6be661b (diff) | |
download | curl-b5726e5549a45671391e88e45b9e0702ff4e7a28.tar.gz |
send_speed: simplify the checks for if a speed limit is set
... as we know the value cannot be set to negative: enforced by
setopt()
Diffstat (limited to 'lib')
-rw-r--r-- | lib/http.c | 2 | ||||
-rw-r--r-- | lib/multi.c | 8 | ||||
-rw-r--r-- | lib/progress.c | 4 |
3 files changed, 7 insertions, 7 deletions
diff --git a/lib/http.c b/lib/http.c index a0da9eade..02c81c419 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1167,7 +1167,7 @@ static size_t readmoredata(char *buffer, /* make sure that a HTTP request is never sent away chunked! */ data->req.forbidchunk = (http->sending == HTTPSEND_REQUEST)?TRUE:FALSE; - if((data->set.max_send_speed > 0) && + if(data->set.max_send_speed && (data->set.max_send_speed < http->postsize)) /* speed limit */ fullsize = (size_t)data->set.max_send_speed; diff --git a/lib/multi.c b/lib/multi.c index cce3149dd..be3e41f8b 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -2069,7 +2069,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, } else { send_timeout_ms = 0; - if(data->set.max_send_speed > 0) + if(data->set.max_send_speed) send_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.uploaded, data->progress.ul_limit_size, @@ -2078,7 +2078,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, *nowp); recv_timeout_ms = 0; - if(data->set.max_recv_speed > 0) + if(data->set.max_recv_speed) recv_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.downloaded, data->progress.dl_limit_size, @@ -2105,7 +2105,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, DEBUGASSERT(data->state.buffer); /* check if over send speed */ send_timeout_ms = 0; - if(data->set.max_send_speed > 0) + if(data->set.max_send_speed) send_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.uploaded, data->progress.ul_limit_size, data->set.max_send_speed, @@ -2114,7 +2114,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi, /* check if over recv speed */ recv_timeout_ms = 0; - if(data->set.max_recv_speed > 0) + if(data->set.max_recv_speed) recv_timeout_ms = Curl_pgrsLimitWaitTime(data->progress.downloaded, data->progress.dl_limit_size, data->set.max_recv_speed, diff --git a/lib/progress.c b/lib/progress.c index 812c16b9a..cc040a873 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -321,14 +321,14 @@ void Curl_pgrsSetDownloadCounter(struct Curl_easy *data, curl_off_t size) void Curl_ratelimit(struct Curl_easy *data, struct curltime now) { /* don't set a new stamp unless the time since last update is long enough */ - if(data->set.max_recv_speed > 0) { + if(data->set.max_recv_speed) { if(Curl_timediff(now, data->progress.dl_limit_start) >= MIN_RATE_LIMIT_PERIOD) { data->progress.dl_limit_start = now; data->progress.dl_limit_size = data->progress.downloaded; } } - if(data->set.max_send_speed > 0) { + if(data->set.max_send_speed) { if(Curl_timediff(now, data->progress.ul_limit_start) >= MIN_RATE_LIMIT_PERIOD) { data->progress.ul_limit_start = now; |