Fix regression causing the main loop to spin more frequently.

Addresses BIT-1266.
This commit is contained in:
Jon Siwek 2014-10-02 11:33:37 -05:00
parent d9889d489f
commit 9cd85be308
2 changed files with 20 additions and 0 deletions

View file

@ -77,6 +77,23 @@ public:
return false; return false;
} }
/**
* @return whether any file descriptors have been added to the set.
*/
bool Empty() const
{
return fds.empty();
}
/**
* @return the greatest file descriptor of all that have been added to the
* set, or -1 if the set is empty.
*/
int Max() const
{
return max;
}
private: private:
int max; int max;
std::set<int> fds; std::set<int> fds;

View file

@ -117,6 +117,9 @@ IOSource* Manager::FindSoonest(double* ts)
src->Clear(); src->Clear();
src->src->GetFds(&src->fd_read, &src->fd_write, &src->fd_except); src->src->GetFds(&src->fd_read, &src->fd_write, &src->fd_except);
if ( src->fd_read.Empty() ) src->fd_read.Insert(0);
if ( src->fd_write.Empty() ) src->fd_write.Insert(0);
if ( src->fd_except.Empty() ) src->fd_except.Insert(0);
src->SetFds(&fd_read, &fd_write, &fd_except, &maxx); src->SetFds(&fd_read, &fd_write, &fd_except, &maxx);
} }