tls: fix connected notifications with no app wrk
[vpp.git] / src / vnet / tls / tls.c
index 5f336cb..3a781eb 100644 (file)
@@ -210,13 +210,16 @@ tls_notify_app_accept (tls_ctx_t * ctx)
 int
 tls_notify_app_connected (tls_ctx_t * ctx, session_error_t err)
 {
+  u32 parent_app_api_ctx;
   session_t *app_session;
   app_worker_t *app_wrk;
 
   app_wrk = app_worker_get_if_valid (ctx->parent_app_wrk_index);
   if (!app_wrk)
     {
-      tls_disconnect_transport (ctx);
+      if (ctx->tls_type == TRANSPORT_PROTO_TLS)
+       session_free (session_get (ctx->c_s_index, ctx->c_thread_index));
+      ctx->no_app_session = 1;
       return -1;
     }
 
@@ -255,8 +258,11 @@ tls_notify_app_connected (tls_ctx_t * ctx, session_error_t err)
     goto failed;
 
   app_session->session_state = SESSION_STATE_READY;
-  if (app_worker_connect_notify (app_wrk, app_session,
-                                SESSION_E_NONE, ctx->parent_app_api_context))
+  parent_app_api_ctx = ctx->parent_app_api_context;
+  ctx->app_session_handle = session_handle (app_session);
+
+  if (app_worker_connect_notify (app_wrk, app_session, SESSION_E_NONE,
+                                parent_app_api_ctx))
     {
       TLS_DBG (1, "failed to notify app");
       app_session->session_state = SESSION_STATE_CONNECTING;
@@ -264,8 +270,6 @@ tls_notify_app_connected (tls_ctx_t * ctx, session_error_t err)
       return -1;
     }
 
-  ctx->app_session_handle = session_handle (app_session);
-
   return 0;
 
 failed: