________________________________________
From: [email protected] [[email protected]] on 
behalf of Daniel Stenberg [[email protected]]
Sent: Tuesday, January 24, 2012 5:42 PM
To: libcurl development
Subject: RE: libcurl PUT retry and READFUNCTION

On Tue, 24 Jan 2012, Wenjun Chen wrote:

> Please don't top-post.
ok, got it. Thank you very much Daniel, for your help. 

>> The libcurl version is 7.21.7. Libcurl returned SUCCESS in this case. And
>> the READFUNCTION only called once and got correct data.

>You forgot the perhaps most important question:

>Did the VERBOSE output show any clues?

My application is linked with libcurl as DLL file, so I don't have verbose 
output even though the CURLOPT is set to verbose in code.  This happens 
intermittent, and it is not easy to reproduce.  

>It could hint if this was a SEEKFUNCTION problem or not. BTW, SEEKFUNCTION is
>documented. Is there anything that isn't clear on how it works?

I am not sure if this is a correct usage?  I will try this and run for a few 
hours to see if the problem is resolved.

                // set the put_data_callback function
                curl_easy_setopt(curl, CURLOPT_PUT, true);  
                curl_easy_setopt(curl, CURLOPT_READDATA, &m_data); 
                curl_easy_setopt(curl, CURLOPT_READFUNCTION, put_data_callback);

                curl_easy_setopt(curl, CURLOPT_SEEKDATA, &m_data);
                curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, 
seek_data_callback); 

                curl_easy_perform(curl);


struct put_data_t {
                const char * data_start; 
                unsigned read_pos; 
                unsigned data_len; 
};

int  seek_data_callback(void *userp,  curl_off_t offset, int origin)
{
                if (!userp) 
                                return 0; 

               put_data_t *userdata = (put_data_t *)userp; 

               if (offset > userdata->data_len)
                      return CURL_SEEKFUNC_FAIL; 
                     

               if (origin == SEEK_SET || origin == SEEK_CUR)
               {
                      userdata->read_pos = offset; 
                      return CURL_SEEKFUNC_OK;
                }
                
                if (origin == SEEK_END)
                {
                       userdata->read_pos = userdata->data_len;
                       return CURL_SEEKFUNC_OK; 
                }

                return CURL_SEEKFUNC_FAIL;                  
 }

Thanks,
wenjun 
 


>--
    

  > / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to