diff options
author | Matthew Smith <mgsmith@netgate.com> | 2022-12-15 22:18:08 +0000 |
---|---|---|
committer | Matthew Smith <mgsmith@netgate.com> | 2023-01-04 17:00:15 +0000 |
commit | 57f177d0b7ad3002ba0d05dc8180f4b342ce5384 (patch) | |
tree | 11ac30259d982629f0a1e91fbc1902dbd03cacae /src/vlibmemory | |
parent | 6c89a35846e6884c69f5df6a28c91dfed5b24cc8 (diff) |
vapi: add vapi_stop_rx_thread()
Type: improvement
Allow vapi to signal to an application's RX thread that it should wake
up and exit.
Before disconnecting from VPP's API, libvlibmemoryclient inserts an
rx_thread_exit message into the client's own input queue to cause its
RX thread to wake up from its blocking dequeue and exit cleanly. Add a
function to vapi's API which will allow libvapi client applications
which have an RX thread waiting for incoming messages using vapi_wait()
to do the same thing.
The existing libvlibmemoryclient code which does this was moved to a
separate function and made available for vapi_stop_rx_thread() to call.
Also fixed some inconsistencies in indentation of function prototypes in
vapi.h to make checkstyle.sh happy.
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Change-Id: I7bbb73470807123cc63ef313cfb91d1fd31b34e5
Diffstat (limited to 'src/vlibmemory')
-rw-r--r-- | src/vlibmemory/memory_client.c | 13 | ||||
-rw-r--r-- | src/vlibmemory/memory_client.h | 1 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/vlibmemory/memory_client.c b/src/vlibmemory/memory_client.c index d2323de0034..c66c71c43b1 100644 --- a/src/vlibmemory/memory_client.c +++ b/src/vlibmemory/memory_client.c @@ -510,6 +510,14 @@ vl_client_connect_to_vlib_thread_fn (const char *svm_name, thread_fn, arg, 1 /* do map */ ); } +void +vl_client_stop_rx_thread (svm_queue_t *vl_input_queue) +{ + vl_api_rx_thread_exit_t *ep; + ep = vl_msg_api_alloc (sizeof (*ep)); + ep->_vl_msg_id = ntohs (VL_API_RX_THREAD_EXIT); + vl_msg_api_send_shmem (vl_input_queue, (u8 *) &ep); +} static void disconnect_from_vlib_internal (u8 do_unmap) @@ -520,10 +528,7 @@ disconnect_from_vlib_internal (u8 do_unmap) if (mm->rx_thread_jmpbuf_valid) { - vl_api_rx_thread_exit_t *ep; - ep = vl_msg_api_alloc (sizeof (*ep)); - ep->_vl_msg_id = ntohs (VL_API_RX_THREAD_EXIT); - vl_msg_api_send_shmem (am->vl_input_queue, (u8 *) & ep); + vl_client_stop_rx_thread (am->vl_input_queue); pthread_join (mm->rx_thread_handle, (void **) &junk); } if (mm->connected_to_vlib) diff --git a/src/vlibmemory/memory_client.h b/src/vlibmemory/memory_client.h index 3b8f671415c..3b9b2d8d959 100644 --- a/src/vlibmemory/memory_client.h +++ b/src/vlibmemory/memory_client.h @@ -62,6 +62,7 @@ int vl_client_connect_to_vlib_no_rx_pthread_no_map (const char *svm_name, int rx_queue_size); void vl_client_install_client_message_handlers (void); u8 vl_mem_client_is_connected (void); +void vl_client_stop_rx_thread (svm_queue_t *vl_input_queue); always_inline memory_client_main_t * vlibapi_get_memory_client_main (void) |