cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: Curllib on vista?

From: Jared Wilkin <JaredW_at_vulcan.com>
Date: Tue, 4 Mar 2008 11:40:34 -0800

>Hi Jared,
>
>Forget previous patch, it isn't the way to go.
>
>
>For testing purposes you might also want to consider not unplugging
>the local PC network cable but the remote cable that goes out of the
>router/switch into destination server.
>
>And this might sound dumb but... Do you get same results in other
>'Hasta La Vista' machines ?
>
>--
>-=[Yang]=-

Yes, I have tried this on at least 3 vista machines all with the same
result. I have found a fix that seems to work...

In transfer.c you will find:

    /* The *_HOLD and *_PAUSE logic is necessary since even though there
might
       be no traffic during the select interval, we still call
       Curl_readwrite() for the timeout case and if we limit transfer
speed we
       must make sure that this function doesn't transfer anything while
in
       HOLD status. */

    switch (Curl_socket_ready(fd_read, fd_write, 1000)) {
    case -1: /* select() error, stop reading */
#ifdef EINTR
      /* The EINTR is not serious, and it seems you might get this more
         ofen when using the lib in a multi-threaded environment! */
      if(SOCKERRNO == EINTR)
        ;
      else
#endif
        done = TRUE; /* no more read or write */
      continue;
    case 0: /* timeout */

Here the case 0 isn't handled it is the timeout case, at this point if
you increment a retries counter up to some defined maximum at which
point you return a CURLE_OPERATION_TIMEDOUT error, this produces the
desired effect. The problem was Curl_socket_ready was always returning
0 in the case where the network went down, but the 0 case wasn't being
handled...

Jared

Ps here is the diff

Index: /curl-7.18.0/lib/transfer.c
===================================================================
--- /curl-7.18.0/lib/transfer.c
+++ /curl-7.18.0/lib/transfer.c
@@ -1733,6 +1733,7 @@
  * <butlerm_at_xmission.com>.
  */
 
+#define MAX_TIMEOUT_TRIES 20
 static CURLcode
 Transfer(struct connectdata *conn)
 {
@@ -1740,6 +1741,7 @@
   struct SessionHandle *data = conn->data;
   struct SingleRequest *k = &data->req;
   bool done=FALSE;
+ int maxTries = 0;
 
   if((conn->sockfd == CURL_SOCKET_BAD) &&
      (conn->writesockfd == CURL_SOCKET_BAD))
@@ -1805,6 +1807,8 @@
         done = TRUE; /* no more read or write */
       continue;
     case 0: /* timeout */
+ if(++maxTries == MAX_TIMEOUT_TRIES)
+ return CURLE_OPERATION_TIMEDOUT;
     default: /* readable descriptors */
 
       result = Curl_readwrite(conn, &done);
Received on 2008-03-04