tls: pass session state to engine on client init

Type: fix

Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: Ibe218a922ab656b8362e3c085193cb848783c255
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index 3096dd5..996c20f 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -582,7 +582,6 @@
 
   ctx->tls_session_handle = session_handle (tls_session);
   tls_session->opaque = ctx_handle;
-  tls_session->session_state = SESSION_STATE_READY;
 
   if (tls_ctx_init_client (ctx))
     {
@@ -590,6 +589,9 @@
       tls_disconnect_transport (ctx);
     }
 
+  if (tls_session->session_state < SESSION_STATE_READY)
+    tls_session->session_state = SESSION_STATE_READY;
+
   return 0;
 }