curl-library
Re: 1st cb of XFERINFOFUNCTION has dltotal from previous perform!
Date: Mon, 12 Jan 2015 12:24:58 +0200
On Mon, Jan 12, 2015 at 12:21:17PM +0200, Mohammad_AlSaleh wrote:
> On Mon, Jan 12, 2015 at 10:24:21AM +0100, Daniel Stenberg wrote:
> > On Mon, 12 Jan 2015, Mohammad_AlSaleh wrote:
> >
> > >If I reuse a handle to do different transfers with different
> > >sizes. (Same URL, different ranges in my case). dltotal is not
> > >guaranteed to to be either the new transfer size or zero. In fact,
> > >the value seems to be left-over from the previous transfer before
> > >it's updated.
> > >
> > >Is this a bug? Or expected behavior.
> >
> > Sounds like a bug to me. Can you help us reproduce the case?
> >
>
> The (summarized) output of the attached use-case:
>
>
> transfer_size=524288, dltotal=0, dlnow=0
> .
> .
> transfer_size=524288, dltotal=0, dlnow=0
> transfer_size=524288, dltotal=524288, dlnow=2401
> .
> .
snip
> transfer_size=524288, dltotal=524288, dlnow=524288
> transfer_size=262144, dltotal=524288, dlnow=0
> .
> .
> ransfer_size=262144, dltotal=524288, dlnow=0
> transfer_size=262144, dltotal=262144, dlnow=2396
Here.
dltotal is not reset. And only updated when dlnow becomes non-zero.
> .
> .
> transfer_size=262144, dltotal=262144, dlnow=262144
>
> > --
> >
> > / daniel.haxx.se
> > -------------------------------------------------------------------
> > List admin: http://cool.haxx.se/list/listinfo/curl-library
> > Etiquette: http://curl.haxx.se/mail/etiquette.html
> #include <curl.h>
>
> int xfer_info_func(void *void_transfer_size, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
> (void)ultotal;
> (void)ulnow;
>
> curl_off_t *transfer_size = void_transfer_size;
> fprintf(stderr, "transfer_size=%jd, dltotal=%jd, dlnow=%jd\n", *transfer_size, dltotal, dlnow);
>
> return 0;
> }
>
> int main() {
> CURL *curl = curl_easy_init();
>
> curl_easy_setopt(curl, CURLOPT_URL, "http://curl.haxx.se/download/curl-7.40.0.tar.gz");
> curl_easy_setopt(curl, CURLOPT_XFERINFOFUNCTION, &xfer_info_func);
> curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0l);
>
> curl_off_t size1 = 524288;
> FILE *f1 = fopen("/tmp/1.part", "wb+");
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, f1);
> curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &size1);
> curl_easy_setopt(curl, CURLOPT_RANGE, "0-524287");
>
>
> if (curl_easy_perform(curl) != CURLE_OK) {
> fprintf(stderr, "transfer 1 failed.\n");
> return 1;
> }
>
> curl_off_t size2 = 262144;
> FILE *f2 = fopen("/tmp/2.part", "wb+");
> curl_easy_setopt(curl, CURLOPT_WRITEDATA, f2);
> curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &size2);
> curl_easy_setopt(curl, CURLOPT_RANGE, "524288-786431");
>
> if (curl_easy_perform(curl) != CURLE_OK) {
> fprintf(stderr, "transfer 2 failed.\n");
> return 1;
> }
>
> curl_easy_cleanup(curl);
> return 0;
> }
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-01-12