Fix high CPU usage when running the SDK server
It was coming from `recv_select()` and `accept_select()` The timeval struct members for select() is reset after each call to select() for whatever reason so like FD_ZERO and FD_SET it needs to be placed inside the loop. Source: https://stackoverflow.com/questions/3324078/why-select-always-return-0-after-the-first-timeout
This commit is contained in:
parent
a3c931392a
commit
1db412e970
2 changed files with 11 additions and 8 deletions
|
|
@ -230,11 +230,12 @@ int NetworkClient::recv_select(SOCKET s, char *buf, int len, int flags)
|
|||
{
|
||||
fd_set set;
|
||||
struct timeval timeout;
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
while(1)
|
||||
{
|
||||
timeout.tv_sec = 5;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
FD_ZERO(&set); /* clear the set */
|
||||
FD_SET(s, &set); /* add our file descriptor to the set */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue