]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Fix the "lingering close" problem when re-using a connection, as test case
authorDaniel Stenberg <daniel@haxx.se>
Wed, 21 Apr 2004 08:49:14 +0000 (08:49 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 21 Apr 2004 08:49:14 +0000 (08:49 +0000)
160 shows.

We got no data and we attempted to re-use a connection. This might happen if
the connection was left alive when we were done using it before, but that was
closed when we wanted to read from it again. Bad luck. Retry the same request
on a fresh connect!

Deleted the sockerror variable again, it serves no purpose anymore.

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

index 79f8d51fb036de80b3f8b9d1d4f3fadc116ff4f2..896e42c682e5d259ccd96ea52955584a0e7a0bbe 100644 (file)
@@ -417,7 +417,6 @@ int Curl_read(struct connectdata *conn, /* connection data */
 
     if(-1 == nread) {
       int err = Curl_ourerrno();
-      conn->sockerror = err;
 #ifdef WIN32
       if(WSAEWOULDBLOCK == err)
 #else
@@ -425,8 +424,6 @@ int Curl_read(struct connectdata *conn, /* connection data */
 #endif
         return -1;
     }
-    else
-      conn->sockerror = 0; /* no error */
 
 #ifdef USE_SSLEAY
   }
index cb24dd30fdb900be2b6a23e4d57344005685f94d..2d0b4aa3336a4af1af18cbbe3bfda955d80a646b 100644 (file)
@@ -1946,15 +1946,14 @@ CURLcode Curl_perform(struct SessionHandle *data)
         res = Transfer(conn); /* now fetch that URL please */
         if(res == CURLE_OK) {
 
-          if((conn->keep.bytecount == 0) &&
-             (conn->sockerror == ECONNRESET) &&
+          if((conn->keep.bytecount+conn->headerbytecount == 0) &&
              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");
+            /* We got no data and we attempted to re-use a connection. This
+               might happen if the connection was left alive when we were done
+               using it before, but that was closed when we wanted to read
+               from it again. Bad luck. Retry the same request on a fresh
+               connect! */
+            infof(data, "Connection died, retrying a fresh connect\n");
             newurl = strdup(conn->data->change.url);
 
             conn->bits.close = TRUE; /* close this connection */
index a4040d15e5613404600ca5e7572bc1ffd7804bcf..55070ccbfdb29bd344be1e56c9f1664e01d0ceb5 100644 (file)
@@ -577,8 +577,6 @@ struct connectdata {
                                single requests! */
   struct ntlmdata proxyntlm; /* NTLM data for proxy */
 
-  int sockerror; /* errno stored by Curl_read() if the underlying layer returns
-                    error */
   char syserr_buf [256]; /* buffer for Curl_strerror() */
 
 #if defined(USE_ARES) || defined(USE_THREADING_GETHOSTBYNAME)