cURL / Mailing Lists / curl-library / Single Mail


RE: libcurl PUT retry and READFUNCTION

From: Wenjun Chen <>
Date: Wed, 25 Jan 2012 14:34:12 +0000

>-----Original Message-----
>From: [] On Behalf Of Dan Fandrich
>Sent: Wednesday, January 25, 2012 12:23 AM
>Subject: Re: libcurl PUT retry and READFUNCTION

>On Wed, Jan 25, 2012 at 04:13:09AM +0000, Wenjun Chen wrote:
>> The above code did not fix the problem. I added log message in call back funcgtions. The log output is as follows.
>> 2012-01-24 22:59:22.000 (GMT-05:00) Write Data is 489 bytes
>> 2012-01-24 22:59:22.000 (GMT-05:00) put_data_callback buff length
>> 16372, data passed in 489 bytes
>> 2012-01-24 22:59:22.000 (GMT-05:00) seek_data_callback, offset: 0,
>> origin: 0, data len: 0
>> Looks like the put_data_callback is not called again after seek_data callback with SEEK_SET operation(the seek_data_callback returns CURL_SEEKFUNC_OK) . Also the data passed back in seek_data_callback is not correct (the datalen should be 489, not 0). Maybe my implementation of seek_data_callback is not correct.

>data_len is entirely controlled by your application's code; it's entirely opaque to libcurl. If it's wrong when it's passed in to the seek callback, then (barring a serious bug in libcurl), it is probably being corrupted elsewhere. That >seek data struct isn't stored on the stack by any chance, is it?
Thanks Dan for the response. No it is not on the stack. The same data is passed in the put_data_callback and the length is fine there (489 bytes), data is copied when put_data_callback is called. It is possible that I may misuse the seek_data_callback, I coded based on my understanding of the document.

The code looks like this.

Put_data_t *data = malloc(sizeof(put_data_t));
data->buff = malloc(489); ( The buff is filled with data).
data->read__pos = 0;
data->data_len = 489;
curl_easy_setopt(curl, CURLOPT_READDATA, &data); #### Note, the same data is passed in to the put_data_callback, when put_data_callback is called, data is fine.
curl_easy_setopt(curl, CURLOPT_READFUNCTION, put_data_callback);
curl_easy_setopt(curl, CURLOPT_SEEKDATA, &data); #### It is the same data that passed in to the put_data_callback.
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, seek_data_callback);


>>> Dan
List admin:

List admin:
Received on 2012-01-25