diff --git a/src/iosource/FD_Set.h b/src/iosource/FD_Set.h index 402d28b8cb..61e3e7a59b 100644 --- a/src/iosource/FD_Set.h +++ b/src/iosource/FD_Set.h @@ -77,6 +77,23 @@ public: 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: int max; std::set fds; diff --git a/src/iosource/Manager.cc b/src/iosource/Manager.cc index 26a48c2911..5a087bc4ef 100644 --- a/src/iosource/Manager.cc +++ b/src/iosource/Manager.cc @@ -117,6 +117,9 @@ IOSource* Manager::FindSoonest(double* ts) src->Clear(); 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); }