cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: FTP download speed throttling

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 16 Apr 2013 23:10:40 +0200 (CEST)

On Tue, 16 Apr 2013, Andrea Narciso wrote:

> 1) I can set the download speed for a connection by setting
> CURLOPT_MAX_RECV_SPEED_LARGE and CURLOPT_BUFFERSIZE parameters at startup.
> Are these parameters meant to be changed at runtime? Some old threads hint
> at this, but nobody was sure if the approach was actually feasible or even
> safe.

*All* options are meant to be set before the transfer starts. Many _can_ be
altered during a transfer but we've tried to not make such guarantees to avoid
trouble.

This said, we could of course at some point start documenting which options
that should be possible to change mid-transfer. You could help us drive that!

> 2) Somebody suggested pausing the connection, changing the aforementioned
> parameters and resuming. Is this approach fine? Are there any
> limitations/drawbacks?

That's still mid-transfer and I doubt pausing/unpausing will change a lot.

> 3) I also considered the "rough" approach: implementing some kind of
> variable delay inside the CURLOPT_WRITEFUNCTION callback. This is my least
> favourite solution as I do not know enough of libcurl internal structure, so
> having a somewhat blocking callback could be quite risky (e.g. impairing
> libcurl operations, triggering timeouts in the FTP server etc.). Is this
> approach also viable?

That's how we implemented throtteling in the beginning so it certainly works
and it doesn't change any options mid-transfer. It does have the unfortunate
side-effect that you can't do anything else in that thread while it is
sleeping.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-16