summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikael Helbo Kjær <mhk@designtech.dk>2010-09-01 18:39:12 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-09-01 18:39:12 +0200
commit59315ebdcb565d23ba78ba0ca8581cef465fc9bd (patch)
treeaf1906ad4980fa6cb4149e4d24d7b31b86dd7c70 /src
parent99ddfa7d65a4556bdbb68fd1831e2de73595f0c7 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/select.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/select.cpp b/src/select.cpp
index be5cd47..7345cbb 100644
--- a/src/select.cpp
+++ b/src/select.cpp
@@ -217,10 +217,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;