cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Changing CURLOPT_MAX_RECV_SPEED_LARGE during a transfer

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sat, 1 Sep 2012 20:40:23 +0200 (CEST)

On Fri, 31 Aug 2012, Robert Foreman wrote:

> I'm trying to limit the download speed of a transfer, but only once the file
> is partly downloaded. I've done this by using the PROGRESSFUNCTION callback,
> in which I wait until (say) 10% of the file is downloaded and then call
> CURLOPT_MAX_RECV_SPEED_LARGE to set a rate limit.
>
> It appears to work, but I'd like to know whether this is reliable or whether
> it might break on another system.

I think it is reliable, even if it A) isn't documented to be so and B) the
rate limiting is done on the _total_ transfer speed since the transfer started
which makes it act a bit surprising to some. I'd say we have a reason to look
over this handling at some point.

> The second thing I'd like to do is be able to change the rate limit at
> regular intervals while the transfer is in progress. The obvious way would
> be to have a second thread that calls CURLOPT_MAX_RECV_SPEED_LARGE at
> regular intervals, but I can't do that without sharing the curl handle
> between threads. Is there a way to do this?

No, there's really no safe way you can do that. You're better off setting the
new rate in the same thread,

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-01