cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Help w/ HTTP file upload [bug?]

From: Ryan M. Lederman <lederman_at_gmail.com>
Date: Tue, 15 Dec 2009 14:34:06 -0700

Daniel,

After doing some debugging, it seems like even defining USE_BLOCKING_SOCKETS
is not causing a synchronous call to send() to occur. If I do some debug
output when doing HTTP form-based uploading, my callback gets called all the
way from 0% to 100% in about 2msec. It THEN is called at one second
intervals *at 100% every time.*

I verified the same behavior in another app I'm aware of that uses libcurl (
http://screenie.net/), so I'm pretty sure this is a bug. In screenie, there
is default support for ImageShack HTTP uploading. The progress meter
immediately goes to 100% and stays there until the upload is actually
complete.

I have included some debug output to show what I mean: (first number =
ulnow, second = ultotal, third = cpu tick counter (msec). if ultotal ==
ulnow, i output "done!")

LR::FileUploader::OnProgress: 0.000000, 400861.000000, 448296235
LR::FileUploader::OnProgress: 0.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 429.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 16813.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 33197.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 49581.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 65965.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 82349.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 98733.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 115117.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 131501.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 147885.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 164269.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 180653.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 197037.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 213421.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 229805.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 246189.000000, 400861.000000, 448296313
LR::FileUploader::OnProgress: 262573.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 278957.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 295341.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 311725.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 328109.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 344493.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 360877.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 377261.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 393645.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: 400813.000000, 400861.000000, 448296329
LR::FileUploader::OnProgress: done! 448296329
LR::FileUploader::OnProgress: done! 448296329
LR::FileUploader::OnProgress: done! 448297327
LR::FileUploader::OnProgress: done! 448298325
LR::FileUploader::OnProgress: done! 448298357
LR::FileUploader::OnProgress: done! 448298357
LR::FileUploader::OnProgress: done! 448298357
LR::FileUploader::OnProgress: done! 448298357

As far as I can tell, those first n calls to send are being performed
asynchronously, even though USE_BLOCKING_SOCKETS is defined.

Please advise.

On Thu, Dec 10, 2009 at 2:37 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Wed, 9 Dec 2009, Ryan M. Lederman wrote:
>
> **Actual behavior**: curl appears to call the callback in quick succession
>> about 50 times, seemingly while reading the file from disk, THEN begins
>> calling the progress callback at ~1sec intervals where ulnow == ultotal
>> every call (apparently while actually uploading).
>>
>
> In current libcurl the progress callback might get called a lot more often
> than once per second but it should really not be any _less_ frequent than
> so.
>
> I can't see why see this behavior you describe, as the progress meter and
> in fact the entire upload procedure is pretty much the same for formbased
> uploads as for everything else.
>
> Can you provide us with a small example code we can try to see if we can
> repeat/explain/fix/excuse/talk away it?
>
>
> My next attempt at solving was going to be implementing manual file
>> reading via curl_easy_setopt(CURLOPT_READFUNCTION).
>>
>
> Right, that's of course always an option but then you'll need to do a
> little more magic on your own.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-- 
"Liberty can not be preserved without a general knowledge among the people."
- John Adams
-- Ryan M. Lederman

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-15