Skip to content

When the download file is less than the limit speed, it cannot be limited #2371

@liupeidong0620

Description

@liupeidong0620

I did this

Download file size:

[root@california src]# du -sh curl-7.58.0.tar.gz
3.8M	curl-7.58.0.tar.gz

Problems with the new version:

[root@california src]# ./curl -V
curl 7.57.0 (x86_64-pc-linux-gnu) libcurl/7.57.0 OpenSSL/1.0.2h
Release-Date: 2017-11-29
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL TLS-SRP UnixSockets HTTPS-proxy

[root@california src]# time ./curl https://curl.haxx.se/download/curl-7.58.0.tar.gz -O --limit-rate 4M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3788k  100 3788k    0     0  3788k      0  0:00:01 --:--:--  0:00:01 28.6M

real	0m0.145s
user	0m0.033s
sys	0m0.021s

Real download time: real 0m0.145s

I expected the following

Correct performance

[root@california src]# ./curl -V
curl 7.36.0 (x86_64-unknown-linux-gnu) libcurl/7.36.0 OpenSSL/1.0.2h
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL TLS-SRP

[root@california src]# time ./curl https://curl.haxx.se/download/curl-7.58.0.tar.gz -O --limit-rate 4M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3788k  100 3788k    0     0  4110k      0 --:--:-- --:--:-- --:--:-- 4113k

real	0m0.936s
user	0m0.027s
sys	0m0.013s

Real download time: real 0m0.936s

The reason for the problem is here

long Curl_pgrsLimitWaitTime(curl_off_t cursize,
                            curl_off_t startsize,
                            curl_off_t limit,
                            struct curltime start,
                            struct curltime now)
{
  ...........

  /* not enough data yet */
  if(size < limit)
    return -1;

  ..........
}

When the download file is less than the limit speed, it cannot be limited

After this code comment, execute the program:

[root@california src]# ./curl -V
curl 7.57.0 (x86_64-pc-linux-gnu) libcurl/7.57.0 OpenSSL/1.0.2h
Release-Date: 2017-11-29
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL TLS-SRP UnixSockets HTTPS-proxy

[root@california src]# time ./curl https://curl.haxx.se/download/curl-7.58.0.tar.gz -O --limit-rate 4M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3788k  100 3788k    0     0  3788k      0  0:00:01 --:--:--  0:00:01 4052k

real	0m0.950s
user	0m0.026s
sys	0m0.015s

Real download time: real 0m0.950s

operating system

Linux california 4.13.2-1.el7.elrepo.x86_64 #1 SMP Wed Sep 13 18:48:00 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions