hsa: detach app on unsuccessful listen 37/38837/2
authorFilip Tehlar <ftehlar@cisco.com>
Tue, 16 May 2023 13:32:17 +0000 (15:32 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Tue, 16 May 2023 22:07:03 +0000 (22:07 +0000)
Type: fix

Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
Change-Id: Idba74f880a251dbeec2205ee41e16b40d4799b06

src/plugins/hs_apps/http_cli.c

index d742121..5d4d49c 100644 (file)
@@ -555,6 +555,17 @@ hcs_listen ()
   return rv;
 }
 
+static void
+hcs_detach ()
+{
+  vnet_app_detach_args_t _a, *a = &_a;
+  hcs_main_t *hcm = &hcs_main;
+  a->app_index = hcm->app_index;
+  a->api_client_index = APP_INVALID_INDEX;
+  hcm->app_index = ~0;
+  vnet_application_detach (a);
+}
+
 static int
 hcs_create (vlib_main_t *vm)
 {
@@ -572,6 +583,7 @@ hcs_create (vlib_main_t *vm)
     }
   if (hcs_listen ())
     {
+      hcs_detach ();
       clib_warning ("failed to start listening");
       return -1;
     }