cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl, squid proxy, failing multipart post

From: <man_at_tfhs.net>
Date: Tue, 10 May 2005 14:28:32 -0000

>> nearly every time i add debug fprintfs, it makes the thing work, but i have
>> managed to get the problem to manifest with prints in http.c, transfer.c,
>> and sendf.c, and everything looks normal return values of 0 and
>> bytes_transfered positive numbers all around.
>>
>> i am unsure just how these inter-relate, and how the processing continues,
>> but Curl_readwrite keeps getting called, but does not seem to notice that
>> the connect is closed?
>
> If sread() or swrite() (they are macros and are really calling recv() and
> send()) never return -1, libcurl will continue waiting for the proper amount
> of data to get sent *and* received.
>
> If recv() returns 0, it will be treated as the end of the download but libcurl
> continue waiting for the upload to complete.
>
> So, I'm kind of puzzled here since I'm looking for when/why libcurl gets the
> info that the connection is gone and why it doesn't abort the operation then.
>
> But if send() returns zero it means the socket went writable but that nothing
> could be written to it. I guess that's a kind of an error we could use as
> signal to bail out. The current code assumes that it will get -1 back and a
> suitable errno set for that situation...
>
> Can you see if that is the case? You can try modifying the condition in the
> bottom of the Curl_write() function in lib/sendf.c (line 276 in my version).
>

transfer.c, line 288 calls Curl_select(). curl select returns 4 (error).
the code below line 288 only looks for the lowest two bits of the return
(read and write). it does nothing with the error at all. it also appears
to have done nothing with the results it has read thusfar from the server,
so it does not notice the 407?

sendf.c line 317 Curl_write bytes_written: 232
transfer.c line 289, curl_readwrite select_res: 3
transfer.c line 295, curl_readwrite reading
sendf.c line 427 Curl_read nread: 1731
transfer.c line 1184, curl_readwrite writing
sendf.c line 317 Curl_write bytes_written: 13032
transfer.c line 1411, curl_readwrite returning
transfer.c line 289, curl_readwrite select_res: 4

those last two repeat till timeout.

my trivial code change sofar has been to if(error){return
CURLE_SEND_ERROR;}
but that is not really good, since i dont actually know if it was a SEND
or a RECV error (curl_select does not say), and we actually have all the
data we need to do the retransmit with auth. what it should do (i guess),
is something like:

if(error){
  look in read buffer for 407
  jump to retransmit with auth code
}

allan
Received on 2005-05-10