+ n_workers = vlib_num_workers ();
+ vec_validate (fds, 3 /* segs + tx evtfd */ + n_workers);
+
+ /* Send event queues segment */
+ app = application_get (a->app_index);
+ rx_mqs_seg = application_get_rx_mqs_segment (app);
+
+ fd_flags |= SESSION_FD_F_VPP_MQ_SEGMENT;
+ fds[n_fds] = rx_mqs_seg->ssvm.fd;
+ n_fds += 1;
+
+ /* Send fifo segment fd if needed */
+ if (ssvm_type (a->segment) == SSVM_SEGMENT_MEMFD)
+ {
+ fd_flags |= SESSION_FD_F_MEMFD_SEGMENT;
+ fds[n_fds] = a->segment->fd;
+ n_fds += 1;
+ }
+ if (a->options[APP_OPTIONS_FLAGS] & APP_OPTIONS_FLAGS_EVT_MQ_USE_EVENTFD)
+ {
+ fd_flags |= SESSION_FD_F_MQ_EVENTFD;
+ fds[n_fds] = svm_msg_q_get_eventfd (a->app_evt_q);
+ n_fds += 1;
+ }
+
+ if (application_use_private_rx_mqs ())
+ {
+ fd_flags |= SESSION_FD_F_VPP_MQ_EVENTFD;
+ for (i = 0; i < n_workers + 1; i++)
+ {
+ rx_mq = application_rx_mq_get (app, i);
+ fds[n_fds] = svm_msg_q_get_eventfd (rx_mq);
+ n_fds += 1;
+ }
+ }
+
+done:
+
+ msg.type = APP_SAPI_MSG_TYPE_ATTACH_REPLY;
+ rmp = &msg.attach_reply;
+ rmp->retval = rv;
+ if (!rv)
+ {
+ ctrl_thread = n_workers ? 1 : 0;
+ rmp->app_index = a->app_index;
+ rmp->app_mq =
+ fifo_segment_msg_q_offset ((fifo_segment_t *) a->segment, 0);
+ rmp->vpp_ctrl_mq = fifo_segment_msg_q_offset (rx_mqs_seg, ctrl_thread);
+ rmp->vpp_ctrl_mq_thread = ctrl_thread;
+ rmp->n_fds = n_fds;
+ rmp->fd_flags = fd_flags;
+ /* No segment name and size since we only support memfds
+ * in this configuration */
+ rmp->segment_handle = a->segment_handle;
+ rmp->api_client_handle = a->api_client_index;
+
+ /* Update app index for socket */
+ handle = (app_ns_api_handle_t *) & cs->private_data;
+ app_wrk = application_get_worker (app, 0);
+ handle->aah_app_wrk_index = app_wrk->wrk_index;
+ }
+
+ clib_socket_sendmsg (cs, &msg, sizeof (msg), fds, n_fds);
+ vec_free (a->name);
+ vec_free (fds);
+}
+
+void
+sapi_socket_close_w_handle (u32 api_handle)
+{
+ app_namespace_t *app_ns = app_namespace_get (api_handle >> 16);
+ u16 sock_index = api_handle & 0xffff;
+ app_ns_api_handle_t *handle;
+ clib_socket_t *cs;
+ clib_file_t *cf;
+
+ cs = appns_sapi_get_socket (app_ns, sock_index);
+ if (!cs)