From a353086e97331bb89570df615f04b5745e4e7920 Mon Sep 17 00:00:00 2001 From: Christian Giese Date: Fri, 23 Feb 2024 17:34:52 +0000 Subject: [PATCH] fix high cpu in ctrl socket thread --- code/bngblaster/src/bbl_ctrl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/bngblaster/src/bbl_ctrl.c b/code/bngblaster/src/bbl_ctrl.c index 37e1e5ee..e18fa66f 100644 --- a/code/bngblaster/src/bbl_ctrl.c +++ b/code/bngblaster/src/bbl_ctrl.c @@ -354,6 +354,10 @@ bbl_ctrl_socket_thread(void *thread_data) timeout.tv_sec = 1; timeout.tv_usec = 0; + struct timespec sleep, rem; + sleep.tv_sec = 0; + sleep.tv_nsec = 10 * MSEC; + ctrl->active = true; while(ctrl->active) { fd = accept(ctrl->socket, 0, 0); @@ -481,7 +485,9 @@ CLOSE: shutdown(fd, SHUT_WR); select(fd + 1, &read_fds, NULL, NULL, &timeout); close(fd); - } + } else { + nanosleep(&sleep, &rem); + } } return NULL; }