summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-16 18:47:27 +0000
committerAndrew Yourtchenko <ayourtch@gmail.com>2020-08-13 17:20:47 +0000
commit8f8c625f2155b9151a6727235a50466add358397 (patch)
tree67089fddeb0d0bdf728ef507ebd95758d5c2bb4e
parent5854884d5462bdb440c32969eb7aa2c0ed0ad467 (diff)
vcl: fix app destroy
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I21daa87b1a301142270a1bf20680dd9e9395aac9 (cherry picked from commit ce815deb72fd3941b000aecec931131afc9d6c34)
-rw-r--r--src/vcl/vcl_cfg.c2
-rw-r--r--src/vcl/vcl_private.h1
-rw-r--r--src/vcl/vppcom.c39
3 files changed, 21 insertions, 21 deletions
diff --git a/src/vcl/vcl_cfg.c b/src/vcl/vcl_cfg.c
index 21fa0fad2b0..05da4686e7f 100644
--- a/src/vcl/vcl_cfg.c
+++ b/src/vcl/vcl_cfg.c
@@ -19,7 +19,7 @@
* Do not access it directly -- use vcm which will point to
* the heap allocated copy after init.
*/
-static vppcom_main_t _vppcom_main = {
+vppcom_main_t _vppcom_main = {
.debug = VPPCOM_DEBUG_INIT,
.is_init = 0,
.app_index = ~0,
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index 0cd6a6c7944..2d0e2ccfc04 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -349,6 +349,7 @@ typedef struct vppcom_main_t_
} vppcom_main_t;
extern vppcom_main_t *vcm;
+extern vppcom_main_t _vppcom_main;
#define VCL_INVALID_SESSION_INDEX ((u32)~0)
#define VCL_INVALID_SESSION_HANDLE ((u64)~0)
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index 49394e4f69c..0925246f8a1 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -1090,35 +1090,34 @@ vppcom_app_create (char *app_name)
void
vppcom_app_destroy (void)
{
- int rv;
- f64 orig_app_timeout;
+ struct dlmallinfo mi;
+ vcl_worker_t *wrk;
+ mspace heap;
if (!pool_elts (vcm->workers))
return;
vcl_evt (VCL_EVT_DETACH, vcm);
- if (pool_elts (vcm->workers) == 1)
- {
- vcl_send_app_detach (vcl_worker_get_current ());
- orig_app_timeout = vcm->cfg.app_timeout;
- vcm->cfg.app_timeout = 2.0;
- rv = vcl_wait_for_app_state_change (STATE_APP_ENABLED);
- vcm->cfg.app_timeout = orig_app_timeout;
- if (PREDICT_FALSE (rv))
- VDBG (0, "application detach timed out! returning %d (%s)", rv,
- vppcom_retval_str (rv));
- vec_free (vcm->app_name);
- vcl_worker_cleanup (vcl_worker_get_current (), 0 /* notify vpp */ );
- }
- else
- {
- vcl_worker_cleanup (vcl_worker_get_current (), 1 /* notify vpp */ );
- }
+ vcl_send_app_detach (vcl_worker_get_current ());
+
+ /* *INDENT-OFF* */
+ pool_foreach (wrk, vcm->workers, ({
+ vcl_worker_cleanup (wrk, 0 /* notify vpp */ );
+ }));
+ /* *INDENT-ON* */
- vcl_set_worker_index (~0);
vcl_elog_stop (vcm);
vl_client_disconnect_from_vlib ();
+
+ /*
+ * Free the heap and fix vcm
+ */
+ heap = clib_mem_get_heap ();
+ mi = mspace_mallinfo (heap);
+ munmap (mspace_least_addr (heap), mi.arena);
+
+ vcm = &_vppcom_main;
}
int