]> granicus.if.org Git - curl/commitdiff
Somewhat crude attempt at fixing the test 91 failures. I commit this now
authorDaniel Stenberg <daniel@haxx.se>
Fri, 30 Jan 2004 12:08:18 +0000 (12:08 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 30 Jan 2004 12:08:18 +0000 (12:08 +0000)
so that the automatic testing hosts will test these changes over the weekend.

lib/sendf.c
lib/setup.h
lib/transfer.c
lib/urldata.h

index fe3cbb422e928ba4279bc4bcade54739425c4d16..c9eb62f5fddb79934e815673f2573e73c5bcc1c0 100644 (file)
@@ -420,6 +420,7 @@ int Curl_read(struct connectdata *conn,
 
     if(-1 == nread) {
       int err = Curl_ourerrno();
+      conn->sockerror = err;
 #ifdef WIN32
       if(WSAEWOULDBLOCK == err)
 #else
index 20120d8a6f3677c4bb6d342b65604476fdeb6bf5..3ba33dd3203d8c4a28bd8bf19970db954a696eac 100644 (file)
@@ -256,4 +256,14 @@ typedef struct in_addr Curl_ipconnect;
 #define IOCTL_3_ARGS
 #endif
 
+#ifndef ECONNRESET
+#ifdef WSAECONNRESET
+#define ECONNRESET WSAECONNRESET
+#else
+/* This will effectively prevent the code from working in this particular
+   aspect, but it still compile fine! */
+#define ECONNRESET 10000
+#endif
+#endif
+
 #endif /* __CONFIG_H */
index eb0c99452db8a75adb8fa5236d7476ecd6d605ee..8e5d6abd39d9f29c89b081d171b0e00b2592655b 100644 (file)
@@ -1896,12 +1896,26 @@ CURLcode Curl_perform(struct SessionHandle *data)
 
       if(res == CURLE_OK) {
         res = Transfer(conn); /* now fetch that URL please */
-        if(res == CURLE_OK)
-          /*
-           * We must duplicate the new URL here as the connection data
-           * may be free()ed in the Curl_done() function.
-           */
-          newurl = conn->newurl?strdup(conn->newurl):NULL;
+        if(res == CURLE_OK) {
+
+          if((conn->keep.bytecount == 0) &&
+             (conn->sockerror == ECONNRESET) &&
+             conn->bits.reuse) {
+            /* We got no data, the connection was reset and we did attempt
+               to re-use a connection. This smells like we were too fast to
+               re-use a connection that was closed when we wanted to read
+               from it. Bad luck. Let's simulate a redirect to the same URL
+               to retry! */
+            infof(data, "Connection reset, retrying a fresh connect\n");
+            newurl = strdup(conn->data->change.url);
+          }
+          else
+            /*
+             * We must duplicate the new URL here as the connection data
+             * may be free()ed in the Curl_done() function.
+             */
+            newurl = conn->newurl?strdup(conn->newurl):NULL;
+        }
         else {
           /* The transfer phase returned error, we mark the connection to get
            * closed to prevent being re-used. This is becasue we can't
index f4a923817b2daf35116f5a738d0c19e18ad0a118..49a38dfb24439144f04c6849a4e9dbe0fad61964 100644 (file)
@@ -563,6 +563,8 @@ struct connectdata {
                                single requests! */
   struct ntlmdata proxyntlm; /* NTLM data for proxy */
 
+  int sockerror; /* errno stored by Curl_read() if the underlying layer returns
+                    error */
 #ifdef USE_ARES
   /* data used for the asynch name resolve callback */
   struct Curl_async async;