aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vcl/vcl_private.c4
-rw-r--r--src/vcl/vppcom.c9
2 files changed, 12 insertions, 1 deletions
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index 95cc0bfc3f4..589380d27aa 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -138,6 +138,9 @@ vcl_api_app_worker_add (void)
void
vcl_api_app_worker_del (vcl_worker_t * wrk)
{
+ if (wrk->api_client_handle == ~0)
+ return;
+
if (vcm->cfg.vpp_app_socket_api)
return vcl_sapi_app_worker_del (wrk);
@@ -249,6 +252,7 @@ vcl_worker_alloc_and_init ()
wrk = vcl_worker_alloc ();
vcl_set_worker_index (wrk->wrk_index);
+ wrk->api_client_handle = ~0;
wrk->thread_id = pthread_self ();
wrk->current_pid = getpid ();
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 0e81749224e..7fffc3bcbe2 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -1286,6 +1286,9 @@ vcl_api_handle_disconnect (vcl_worker_t *wrk)
static void
vcl_api_detach (vcl_worker_t * wrk)
{
+ if (wrk->api_client_handle == ~0)
+ return;
+
vcl_send_app_detach (wrk);
if (vcm->cfg.vpp_app_socket_api)
@@ -1328,7 +1331,10 @@ vppcom_app_create (const char *app_name)
vcl_worker_alloc_and_init ();
if ((rv = vcl_api_attach ()))
- return rv;
+ {
+ vppcom_app_destroy ();
+ return rv;
+ }
VDBG (0, "app_name '%s', my_client_index %d (0x%x)", app_name,
vcm->workers[0].api_client_handle, vcm->workers[0].api_client_handle);
@@ -1358,6 +1364,7 @@ vppcom_app_destroy (void)
vcl_api_detach (current_wrk);
vcl_worker_cleanup (current_wrk, 0 /* notify vpp */ );
+ vcl_set_worker_index (~0);
vcl_elog_stop (vcm);