cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: CURLOPT_SEEKFUNCTION with CURLFORM_STREAM

From: Andrew Fouts <ajfouts_at_gmail.com>
Date: Sat, 27 Feb 2016 02:24:42 -0600

On Fri, Feb 26, 2016 at 6:33 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Thu, 25 Feb 2016, Andrew Fouts wrote:
>
>> I'm using libcurl to POST form data using a FILE* with the CURLFORM_STREAM
>> option of curl_formadd(). I've noticed that if the connection drops at just
>> the right time, the POST is reattempted without the data from the file. It
>> seems like the file stream position isn't getting reset to the beginning of
>> the file. I found the CURLOPT_SEEKFUNCTION option and set that with a
>> function that performs an fseek() on the FILE*. However, setting that
>> didn't seem to fix the issue or get called.
>>
>> I searched the mailing lists and found
>> https://curl.haxx.se/mail/lib-2013-09/0195.html, which sounds similar to my
>> issue. Did that issue ever get resolved? If not, are there plans to
>> implement a fix for that issue?
>
>
> Oh well, look at that!
>
> No, I can't recall that we ever did any such fix and it probably just
> slipped through and then drowned in the constant flood of other things.
>
> Can you help us write up an as basic stand-alone program as possible that
> does basically the same operation you do, so that we can use that to create
> a test case that 1 - repeats the problem and then 2 - helps us verify a fix?
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

I've got a test client & server that's the closest I could get to the
scenario I'm facing. Since it's a race condition whether or not the
seek function is needed (depends on when the TCP session ends), it
takes a lot of cycles of the test client to get the issue to occur.
However, on my PC (Ubuntu 14.04 with an AMD Phenom II X4 B55 @ 3.2
GHz), I can get the issue to occur every time with the current number
of test cycles set in the client.

It seems like Curl_retry_request() has to get hit so that
Curl_readrewind() is called (at least for my scenario). When
Curl_readrewind() is called, the current logic prevents the
CURLOPT_SEEKFUNCTION from getting called with a CURLFORM_STREAM.

There may be a more deterministic way to test this issue, but
hopefully this at least gets things started! Let me know if you need
more details.

Andrew

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

Received on 2016-02-27