changeset 16459:554774a328b9

lib-http: Fixed previous patch setting connection connected only after SSL handshake. This just caused crashes. The main point was anyway to include the SSL handshake as part of the connect_timeout_msecs. Apparently the easiest way is to set it immediately connected and delay removing the timeout.
author Timo Sirainen <tss@iki.fi>
date Thu, 06 Jun 2013 05:58:16 +0300
parents 12a0c383703e
children 452cecc7e708
files src/lib-http/http-client-connection.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-http/http-client-connection.c	Wed Jun 05 18:21:55 2013 +0300
+++ b/src/lib-http/http-client-connection.c	Thu Jun 06 05:58:16 2013 +0300
@@ -671,7 +671,10 @@
 
 	conn->connected = TRUE;
 	conn->peer->last_connect_failed = FALSE;
-	if (conn->to_connect != NULL)
+
+	if (conn->to_connect != NULL &&
+	    (conn->ssl_iostream == NULL ||
+	     ssl_iostream_is_handshaked(conn->ssl_iostream)))
 		timeout_remove(&conn->to_connect);
 
 	if (conn->client->set.rawlog_dir != NULL &&
@@ -703,7 +706,8 @@
 		*error_r = error;
 		return -1;
 	}
-	http_client_connection_ready(conn);
+	if (conn->to_connect != NULL)
+		timeout_remove(&conn->to_connect);
 	return 0;
 }
 
@@ -742,6 +746,8 @@
 			conn->conn.name, ssl_iostream_get_last_error(conn->ssl_iostream));
 		return -1;
 	}
+
+	http_client_connection_ready(conn);
 	return 0;
 }