Skip to content

Commit

Permalink
Fix missing check for the return value of poll being -1 before readin…
Browse files Browse the repository at this point in the history
…g errno.

This fixes a bug where the process would sometimes use 100% cpu
time (of one cpu).
  • Loading branch information
openglfreak committed Feb 6, 2022
1 parent b6e461f commit fb5f866
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/proxy_unixlib/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ int SOCKUNIXAPI socket_poll(int const socket, thread_exit_event const event, pol
fds[1].fd = event.fds[0];
fds[1].events = POLLIN | POLLPRI | POLLHUP;
fds[1].revents = 0;
while ((nfds = poll(fds, sizeof(fds) / sizeof(fds[0]), -1)) == 0 || errno == EAGAIN || errno == EINTR);
while ((nfds = poll(fds, sizeof(fds) / sizeof(fds[0]), -1)) == 0 ||
(nfds == -1 && (errno == EAGAIN || errno == EINTR)));
if (nfds == -1)
return errno ? errno : -1;

Expand Down

0 comments on commit fb5f866

Please sign in to comment.