summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-06-22 14:20:39 -0700
committerFlorin Coras <fcoras@cisco.com>2021-06-22 14:39:14 -0700
commitc53eb72931bc8c75204141f3952ac7682f0ae697 (patch)
tree00ffed8823b5a14dd09c8954abb5e09ea60dd5d2
parent4f348df8cfcec6378ad0593a5bde527f2cbd9482 (diff)
session: avoid reordering unlisten and connect msg
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ibe32f7965f8cf457c39845713b029c8a4647ee55
-rw-r--r--src/vnet/session/session_node.c39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/vnet/session/session_node.c b/src/vnet/session/session_node.c
index 76080a05690..810c75061af 100644
--- a/src/vnet/session/session_node.c
+++ b/src/vnet/session/session_node.c
@@ -387,15 +387,20 @@ app_mq_detach_handler (void *data)
}
static void
-session_mq_unlisten_handler (void *data)
+session_mq_unlisten_rpc (session_unlisten_msg_t *mp)
{
- session_unlisten_msg_t *mp = (session_unlisten_msg_t *) data;
+ vlib_main_t *vm = vlib_get_main ();
vnet_unlisten_args_t _a, *a = &_a;
app_worker_t *app_wrk;
+ session_handle_t sh;
application_t *app;
+ u32 context;
int rv;
- app_check_thread_and_barrier (session_mq_unlisten_handler, mp);
+ sh = mp->handle;
+ context = mp->context;
+
+ vlib_worker_thread_barrier_sync (vm);
app = application_lookup (mp->client_index);
if (!app)
@@ -403,7 +408,7 @@ session_mq_unlisten_handler (void *data)
clib_memset (a, 0, sizeof (*a));
a->app_index = app->app_index;
- a->handle = mp->handle;
+ a->handle = sh;
a->wrk_map_index = mp->wrk_index;
if ((rv = vnet_unlisten (a)))
clib_warning ("unlisten returned: %d", rv);
@@ -412,7 +417,29 @@ session_mq_unlisten_handler (void *data)
if (!app_wrk)
return;
- mq_send_unlisten_reply (app_wrk, mp->handle, mp->context, rv);
+ vlib_worker_thread_barrier_release (vm);
+
+ mq_send_unlisten_reply (app_wrk, sh, context, rv);
+ clib_mem_free (mp);
+}
+
+static void
+session_mq_unlisten_handler (session_worker_t *wrk, session_evt_elt_t *elt)
+{
+ u32 thread_index = wrk - session_main.wrk;
+ session_unlisten_msg_t *mp, *arg;
+
+ mp = session_evt_ctrl_data (wrk, elt);
+ arg = clib_mem_alloc (sizeof (session_unlisten_msg_t));
+ clib_memcpy_fast (arg, mp, sizeof (*arg));
+
+ if (PREDICT_FALSE (!thread_index))
+ {
+ session_mq_unlisten_rpc (arg);
+ return;
+ }
+
+ session_send_rpc_evt_to_thread_force (0, session_mq_unlisten_rpc, arg);
}
static void
@@ -1468,7 +1495,7 @@ session_event_dispatch_ctrl (session_worker_t * wrk, session_evt_elt_t * elt)
session_mq_listen_uri_handler (session_evt_ctrl_data (wrk, elt));
break;
case SESSION_CTRL_EVT_UNLISTEN:
- session_mq_unlisten_handler (session_evt_ctrl_data (wrk, elt));
+ session_mq_unlisten_handler (wrk, elt);
break;
case SESSION_CTRL_EVT_CONNECT:
session_mq_connect_handler (wrk, elt);