mirror of
https://github.com/rtbrick/bngblaster.git
synced 2024-05-06 15:54:57 +00:00
fix high cpu in ctrl socket thread
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user