vcl: add worker unregister api
[vpp.git] / src / vcl / vppcom.c
index 9a351d8..dcbbfc4 100644 (file)
@@ -822,13 +822,27 @@ static int
 vppcom_session_unbind (u32 session_handle)
 {
   vcl_worker_t *wrk = vcl_worker_get_current ();
+  session_accepted_msg_t *accepted_msg;
   vcl_session_t *session = 0;
+  vcl_session_msg_t *evt;
   u64 vpp_handle;
 
   session = vcl_session_get_w_handle (wrk, session_handle);
   if (!session)
     return VPPCOM_EBADFD;
 
+  /* Flush pending accept events, if any */
+  while (clib_fifo_elts (session->accept_evts_fifo))
+    {
+      clib_fifo_sub2 (session->accept_evts_fifo, evt);
+      accepted_msg = &evt->accepted_msg;
+      vcl_session_table_del_vpp_handle (wrk, accepted_msg->handle);
+      vcl_send_session_accepted_reply (session->vpp_evt_q,
+                                      accepted_msg->context,
+                                      session->vpp_handle, -1);
+    }
+  clib_fifo_free (session->accept_evts_fifo);
+
   vpp_handle = session->vpp_handle;
   session->vpp_handle = ~0;
   session->session_state = STATE_DISCONNECT;
@@ -3343,6 +3357,13 @@ vppcom_worker_register (void)
   return VPPCOM_OK;
 }
 
+void
+vppcom_worker_unregister (void)
+{
+  vcl_worker_cleanup (vcl_worker_get_current (), 1 /* notify vpp */ );
+  vcl_set_worker_index (~0);
+}
+
 int
 vppcom_worker_index (void)
 {