From 171b3f206f415f28fda86d6fa2934d384b77de0b Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Mon, 18 Aug 2025 09:43:34 +0200 Subject: [PATCH] VRTsim: Add a timeout in taps client Add a timeout in nanomsg receive code to allow the client thread to exit cleanly. --- radio/vrtsim/taps_client.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/radio/vrtsim/taps_client.cpp b/radio/vrtsim/taps_client.cpp index 6ebfc450fd..c314c3981c 100644 --- a/radio/vrtsim/taps_client.cpp +++ b/radio/vrtsim/taps_client.cpp @@ -108,8 +108,13 @@ void *client_thread_func(void *args) while (should_run) { int next_buffer = (taps_storage.current_buffer + 1) % NUM_TAPS_BUFFERS; taps_buffer_t *taps_buffer = &taps_storage.taps_buffers[next_buffer]; - int ret = nn_recv(client_thread_args->sock, taps_buffer->taps_msg, MAX_TAPS_MSG_SIZE, 0); + int ret = nn_recv(client_thread_args->sock, taps_buffer->taps_msg, MAX_TAPS_MSG_SIZE, NN_DONTWAIT); if (ret < 0) { + if (errno == EAGAIN) { + // Timeout: no message available, sleep briefly and continue + usleep(100); + continue; + } LOG_E(HW, "nn_recv() failed: errno: %d, %s\n", errno, strerror(errno)); continue; }