session: fix sapi coverity warning
[vpp.git] / src / vnet / session / session_api.c
index 89a30d2..e7f95d2 100644 (file)
@@ -988,7 +988,7 @@ send_session_rules_table_details (session_rules_table_t * srt, u8 fib_proto,
 }
 
 static void
-vl_api_session_rules_dump_t_handler (vl_api_one_map_server_dump_t * mp)
+vl_api_session_rules_dump_t_handler (vl_api_session_rules_dump_t * mp)
 {
   vl_api_registration_t *reg;
   session_table_t *st;
@@ -1225,6 +1225,8 @@ sapi_send_fds (app_worker_t * app_wrk, int *fds, int n_fds)
   app_ns = app_namespace_get (app->ns_index);
   cs_index = appns_sapi_handle_sock_index (app_wrk->api_client_index);
   cs = appns_sapi_get_socket (app_ns, cs_index);
+  if (PREDICT_FALSE (!cs))
+    return;
 
   /* There's no payload for the message only the type */
   smsg.type = APP_SAPI_MSG_TYPE_SEND_FDS;
@@ -1534,6 +1536,7 @@ static clib_error_t *
 sapi_sock_read_ready (clib_file_t * cf)
 {
   app_ns_api_handle_t *handle = (app_ns_api_handle_t *) & cf->private_data;
+  vlib_main_t *vm = vlib_get_main ();
   app_sapi_msg_t msg = { 0 };
   app_namespace_t *app_ns;
   clib_error_t *err = 0;
@@ -1554,6 +1557,8 @@ sapi_sock_read_ready (clib_file_t * cf)
 
   handle = (app_ns_api_handle_t *) & cs->private_data;
 
+  vlib_worker_thread_barrier_sync (vm);
+
   switch (msg.type)
     {
     case APP_SAPI_MSG_TYPE_ATTACH:
@@ -1568,6 +1573,8 @@ sapi_sock_read_ready (clib_file_t * cf)
       break;
     }
 
+  vlib_worker_thread_barrier_release (vm);
+
 error:
   return 0;
 }