Skip to content

Commit

Permalink
Merge pull request #4 from thomasjwinter/master
Browse files Browse the repository at this point in the history
Fix potential busy loop with abnormal poll
  • Loading branch information
carlgsmith authored Nov 26, 2024
2 parents ab7b2aa + 6e1742b commit a48d85a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/iface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ void iface::cleanup()

int iface::poll_all()
{
int no_polls = 0;

if (_map_dirty) {
cleanup();
fixup_pollfds();
Expand Down Expand Up @@ -556,6 +558,7 @@ int iface::poll_all()
bool is_pfd = i++ % 2;

if (!(f_it->revents & POLLIN)) {
no_polls++;
continue;
}

Expand Down Expand Up @@ -596,6 +599,11 @@ int iface::poll_all()
}
}

if (no_polls == _pollfds.size()) {
/* 50 milliseconds to match poll timeout. */
usleep(50000);
}

return 0;
}

Expand Down

0 comments on commit a48d85a

Please sign in to comment.