summaryrefslogtreecommitdiff
path: root/src/select.cpp
diff options
context:
space:
mode:
authorMartin Lucina <mato@kotelna.sk>2010-09-08 15:25:45 +0200
committerMartin Lucina <martin@lucina.net>2012-01-23 08:53:27 +0100
commit90d73cba9cd1d1724f38ed82fc0eefb1781c9c20 (patch)
tree1760872164a93384d1adb90db9c8d41777dbb2a7 /src/select.cpp
parentcf026feae205bfeb7e007f6afd0e8d7b283865c8 (diff)
parent5ba1cb20fe6f6699cef1cc726718e760cd4c9af1 (diff)
Imported Debian patch 2.0.9.dfsg-1debian/2.0.9.dfsg-1
Diffstat (limited to 'src/select.cpp')
-rw-r--r--src/select.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/select.cpp b/src/select.cpp
index be5cd47..59eb83e 100644
--- a/src/select.cpp
+++ b/src/select.cpp
@@ -65,6 +65,10 @@ zmq::select_t::handle_t zmq::select_t::add_fd (fd_t fd_, i_poll_events *events_)
fd_entry_t entry = {fd_, events_};
fds.push_back (entry);
+ // Ensure we do not attempt to select () on more than FD_SETSIZE
+ // file descriptors.
+ zmq_assert (fds.size () <= FD_SETSIZE);
+
// Start polling on errors.
FD_SET (fd_, &source_set_err);
@@ -217,10 +221,13 @@ void zmq::select_t::loop ()
// Destroy retired event sources.
if (retired) {
- for (fd_set_t::size_type i = 0; i < fds.size (); i ++) {
- if (fds [i].fd == retired_fd) {
- fds.erase (fds.begin () + i);
- i --;
+ fd_set_t::iterator it = fds.begin();
+ while (it != fds.end()) {
+ if (it->fd == retired_fd) {
+ it = fds.erase(it);
+ }
+ else {
+ it++;
}
}
retired = false;