diff options
author | Florin Coras <fcoras@cisco.com> | 2018-09-14 13:17:41 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2018-09-15 08:10:57 +0000 |
commit | 4829babd7975b98eff8b152ed302495856a656bb (patch) | |
tree | 2fcb6325385eb228162b19a8a52ddb67163b9cd5 /src/vnet/session | |
parent | b5e94e3c8582a00b920d7b22dd839b94e7ded595 (diff) |
session: ensure detach is done with worker barrier
Change-Id: I98a79f2c3b0268c414dd295c7ebfc561ce049d4b
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r-- | src/vnet/session/application_interface.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c index 1f094ef126b..72a9985dced 100644 --- a/src/vnet/session/application_interface.c +++ b/src/vnet/session/application_interface.c @@ -81,6 +81,15 @@ const char test_srv_key_rsa[] = "oEjPLVNtx8SOj/M4rhaPT3I=\r\n" "-----END PRIVATE KEY-----\r\n"; const u32 test_srv_key_rsa_len = sizeof (test_srv_key_rsa); +#define app_interface_check_thread_and_barrier(_fn, _arg) \ + if (PREDICT_FALSE (vlib_get_thread_index () != 0 || \ + (vlib_worker_threads[0].wait_at_barrier && \ + !vlib_worker_threads[0].wait_at_barrier[0]))) \ + { \ + vlib_rpc_call_main_thread (_fn, (u8 *) _arg, sizeof(*_arg)); \ + return 0; \ + } + static u8 session_endpoint_is_local (session_endpoint_t * sep) { @@ -525,14 +534,15 @@ int vnet_application_detach (vnet_app_detach_args_t * a) { application_t *app; - app = application_get_if_valid (a->app_index); + app = application_get_if_valid (a->app_index); if (!app) { clib_warning ("app not attached"); return VNET_API_ERROR_APPLICATION_NOT_ATTACHED; } + app_interface_check_thread_and_barrier (vnet_application_detach, a); application_free (app); return 0; } @@ -599,12 +609,7 @@ vnet_disconnect_session (vnet_disconnect_args_t * a) local_session_t *ls; /* Disconnect reply came to worker 1 not main thread */ - if (vlib_get_thread_index () == 1) - { - vlib_rpc_call_main_thread (vnet_disconnect_session, (u8 *) a, - sizeof (*a)); - return 0; - } + app_interface_check_thread_and_barrier (vnet_disconnect_session, a); if (!(ls = application_get_local_session_from_handle (a->handle))) return 0; |