cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Curl_read_plain and test 160

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Tue, 7 Oct 2008 13:26:55 -0700

On Thu, Sep 25, 2008 at 09:31:21AM +0200, Daniel Stenberg wrote:
> But I think this mostly proves that the existing "retry request on a
> presumably dead connection" code was a band-aid fix needed because we
> didn't do proper error checking of the recv() call before and I think that
> we should primarily assume that the new way of actually respecting the
> errors is a better way forward.

Here's a patch that lets all the tests pass on my machine, but still
returns an error if a retry doesn't work. It changes Transfer() to return
an CURLE_RECV_ERROR error when select fails, and makes the caller attempt
to retry the connection in that case as well as CURLE_OK. Since any
given connection is only eligable to be retried if it's marked as already
reused, this can only ever happen once, so infinite retries isn't possible.

diff -u -r1.411 transfer.c
--- lib/transfer.c 8 Sep 2008 19:34:58 -0000 1.411
+++ lib/transfer.c 7 Oct 2008 20:17:08 -0000
@@ -1851,7 +1851,7 @@
         ;
       else
 #endif
- done = TRUE; /* no more read or write */
+ return CURLE_RECV_ERROR; /* indicate a network problem */
       continue;
     case 0: /* timeout */
     default: /* readable descriptors */
@@ -2465,15 +2465,16 @@
 
       if(res == CURLE_OK) {
         res = Transfer(conn); /* now fetch that URL please */
- if(res == CURLE_OK) {
+ if((res == CURLE_OK) || (res == CURLE_RECV_ERROR)) {
           bool retry = Curl_retry_request(conn, &newurl);
 
           if(retry) {
+ res = CURLE_OK;
             follow = FOLLOW_RETRY;
             if (!newurl)
               res = CURLE_OUT_OF_MEMORY;
           }
- else {
+ else if (res == CURLE_OK) {
             /*
              * We must duplicate the new URL here as the connection data may
              * be free()ed in the Curl_done() function. We prefer the newurl

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
Received on 2008-10-07