From 84259d1b6aa0c70689895888eda09a93fbe2be68 Mon Sep 17 00:00:00 2001
From: Jiri Hruska <jirka@fud.cz>
Date: Mon, 9 Sep 2013 01:10:11 +0200
Subject: [PATCH 2/4] imap: Speed up SSL connection initialization

Don't wait for the next callback call (usually 1 sec) before
continuing with IMAP specific connection initialization.
---
 lib/imap.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/imap.c b/lib/imap.c
index 2207087..7e16c87 100644
--- a/lib/imap.c
+++ b/lib/imap.c
@@ -1704,11 +1704,13 @@ static CURLcode imap_multi_statemach(struct connectdata *conn, bool *done)
   CURLcode result = CURLE_OK;
   struct imap_conn *imapc = &conn->proto.imapc;
 
-  if((conn->handler->flags & PROTOPT_SSL) && !imapc->ssldone)
+  if((conn->handler->flags & PROTOPT_SSL) && !imapc->ssldone) {
     result = Curl_ssl_connect_nonblocking(conn, FIRSTSOCKET, &imapc->ssldone);
-  else
-    result = Curl_pp_statemach(&imapc->pp, FALSE);
+    if(result || !imapc->ssldone)
+      return result;
+  }
 
+  result = Curl_pp_statemach(&imapc->pp, FALSE);
   *done = (imapc->state == IMAP_STOP) ? TRUE : FALSE;
 
   return result;
-- 
1.7.9.msysgit.0

