]> granicus.if.org Git - curl/commitdiff
multi: better failed connect treatment
authorDaniel Stenberg <daniel@haxx.se>
Thu, 17 Feb 2011 22:51:43 +0000 (23:51 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 18 Feb 2011 22:01:55 +0000 (23:01 +0100)
When failing to connect the protocol during the CURLM_STATE_PROTOCONNECT
state, Curl_done() has to be called with the premature flag set TRUE as
for the pingpong protocols this can be important.

When Curl_done() is called with premature == TRUE, it needs to call
Curl_disconnect() with its 'dead_connection' argument set to TRUE as
well so that any protocol handler's disconnect function won't attempt to
use the (control) connection for anything.

This problem caused the pingpong protocols to fail to disconnect when
STARTTLS failed.

Reported by: Alona Rossen
Bug: http://curl.haxx.se/mail/lib-2011-02/0195.html

lib/multi.c
lib/url.c

index 122f66b40514ef12d5becde182556054078e7530..31127028dd6790b10c4d95e316b6458ec2323f21 100644 (file)
@@ -1189,7 +1189,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
       else if(easy->result) {
         /* failure detected */
         Curl_posttransfer(data);
-        Curl_done(&easy->easy_conn, easy->result, FALSE);
+        Curl_done(&easy->easy_conn, easy->result, TRUE);
         disconnect_conn = TRUE;
       }
       break;
index c0755418280a3b6efa6ffd29dd881de5747fa457..c1dab825464f3b050e7983c6aaf94daad030ddd6 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -5281,7 +5281,7 @@ CURLcode Curl_done(struct connectdata **connp,
   */
   if(data->set.reuse_forbid || conn->bits.close || premature ||
      (-1 == conn->connectindex)) {
-    CURLcode res2 = Curl_disconnect(conn, FALSE); /* close the connection */
+    CURLcode res2 = Curl_disconnect(conn, premature); /* close the connection */
 
     /* If we had an error already, make sure we return that one. But
        if we got a new error, return that. */