cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Changing upload speed while a transfer is active

From: Yoav Steinberg <yoav_at_monfort.co.il>
Date: Thu, 22 Jan 2009 13:17:57 +0200

Daniel Stenberg wrote:
> On Wed, 21 Jan 2009, Yoav Steinberg wrote:
>
>> I'm using the easy api to upload files to a server (http). Upload
>> speed is limited using CURLOPT_MAX_SEND_SPEED_LARGE. Is there any way
>> (from a callback for example) to change the value of
>> CURLOPT_MAX_SEND_SPEED_LARGE while upload is in progress?
>
> We've discussed this in the past, and I think it might work. It hasn't
> really been designed for it so there might be a small risk something odd
> will happen. But you're welcome on working to reduce that risk and then
> we could clarify this situation in the docs!
>

Looking at the code it seems like there should be no problem changing
this parameter from a callback. It actually seems to work.

The problem is that since throttling is calculated based on cumulative
average during the entire transfer, the result of changing the speed
limit during a transfer is that we get a few seconds of no transfer at
all when reducing the limit or a few seconds of unlimited transfer speed
when increasings the limit. This leads to other problems like the
connection dying because of no transfer when reducing the speed.

To solve this I guess I'll need to change the speed calculation based on
some sliding window average and not based on the entire transfer. Before
I start playing around with the transfer speed calculation code to
achieve this, I'd like to know why a cumulative average approach was
chosen in the first place.

- Yoav.
Received on 2009-01-22