Commit 59315ebd authored by Mikael Helbo Kjær's avatar Mikael Helbo Kjær Committed by Martin Sustrik

Erasure of retired fd's in select.cpp causes an assertion in MSVC 2008 STL

I was hitting an issue with an SCL enabled STL library in connection with the
way select_t::loop was erasing retired fd's. The problem as identified by the
SCL assertion was that by the time the iterator given to the erase method was
called it was considered invalid by the library. I am not sure this isn't just
a "quirk" of the MSVC STL library as the other code looks valid to me as well.
parent 99ddfa7d
...@@ -217,10 +217,13 @@ void zmq::select_t::loop () ...@@ -217,10 +217,13 @@ void zmq::select_t::loop ()
// Destroy retired event sources. // Destroy retired event sources.
if (retired) { if (retired) {
for (fd_set_t::size_type i = 0; i < fds.size (); i ++) { fd_set_t::iterator it = fds.begin();
if (fds [i].fd == retired_fd) { while (it != fds.end()) {
fds.erase (fds.begin () + i); if (it->fd == retired_fd) {
i --; it = fds.erase(it);
}
else {
it++;
} }
} }
retired = false; retired = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment