conn->bits.tcpconnect now keeps track of if this connection is connected
authorDaniel Stenberg <daniel@haxx.se>
Fri, 13 Dec 2002 16:15:19 +0000 (16:15 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 13 Dec 2002 16:15:19 +0000 (16:15 +0000)
or not

lib/connect.c
lib/url.c
lib/urldata.h

index 1a4c193eb66d2f55cd068e51b11a769fdd759a5a..151864fd7b7546c296c240b4ceb418894acfd556 100644 (file)
@@ -380,8 +380,8 @@ CURLcode Curl_is_connected(struct connectdata *conn,
       return CURLE_OPERATION_TIMEOUTED;
     }
   }
-  if(conn->protocol & PROT_FILE) {
-    /* we are connected, awesome! */
+  if(conn->bits.tcpconnect) {
+    /* we are connected already! */
     *connected = TRUE;
     return CURLE_OK;
   }
index 9355076743081594408801052c75504e26d884bb..a639ebaa1e19df09fc12ea50f66fa511b1bac4b8 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -1677,6 +1677,12 @@ CURLcode Curl_protocol_connect(struct connectdata *conn,
   struct SessionHandle *data = conn->data;
   CURLcode result=CURLE_OK;
   
+  if(conn->bits.tcpconnect)
+    /* We already are connected, get back. This may happen when the connect
+       worked fine in the first call, like when we connect to a local server
+       or proxy. */
+    return CURLE_OK;
+
   Curl_pgrsTime(data, TIMER_CONNECT); /* connect done */
 
   if(data->set.verbose)
@@ -2299,6 +2305,7 @@ static CURLcode CreateConnection(struct SessionHandle *data,
 
     /* Setup a "faked" transfer that'll do nothing */
     if(CURLE_OK == result) {
+      conn->bits.tcpconnect = TRUE; /* we are "connected */
       result = Curl_Transfer(conn, -1, -1, FALSE, NULL, /* no download */
                              -1, NULL); /* no upload */
     }
@@ -2795,14 +2802,21 @@ static CURLcode CreateConnection(struct SessionHandle *data,
     /* Connect only if not already connected! */
     result = ConnectPlease(conn, hostaddr, &connected);
 
-    if(connected)
+    if(connected) {
       result = Curl_protocol_connect(conn, hostaddr);
+      if(CURLE_OK == result)
+        conn->bits.tcpconnect = TRUE;
+    }
+    else
+      conn->bits.tcpconnect = FALSE;
+
 
     if(CURLE_OK != result)
       return result;
   }
   else {
     Curl_pgrsTime(data, TIMER_CONNECT); /* we're connected already */
+    conn->bits.tcpconnect = TRUE;
     if(data->set.verbose)
       verboseconnect(conn, hostaddr);
   }
index 0a54b0ee4a740f2f857ff8248b865297968d06ca..334b0e63368dd9fd845997f4e5114188fb82e3a1 100644 (file)
@@ -243,6 +243,9 @@ struct ConnectBits {
   bool forbidchunk;   /* used only to explicitly forbid chunk-upload for
                          specific upload buffers. See readmoredata() in
                          http.c for details. */
+  bool tcpconnect;    /* the tcp stream (or simimlar) is connected, this
+                         is set the first time on the first connect function
+                         call */
 };
 
 /*