summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hurton <hurtonm@gmail.com>2010-03-03 00:08:11 +0100
committerMartin Hurton <hurtonm@gmail.com>2010-03-03 08:00:30 +0100
commit708298d798693a19ace9a4811a3760d8de0a5c1d (patch)
tree20c5478b65d45ac9c5c0c401f8252fa4931151c2
parent157a66fc42d46c79edc01f6feed8f482fb5d53f1 (diff)
Fix possible lockups when reading from ZMQ_REP sockets
-rw-r--r--src/rep.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/rep.cpp b/src/rep.cpp
index 755d78e..95ea0b1 100644
--- a/src/rep.cpp
+++ b/src/rep.cpp
@@ -71,13 +71,19 @@ void zmq::rep_t::xdetach_inpipe (class reader_t *pipe_)
active--;
in_pipes.swap (index, active);
out_pipes.swap (index, active);
+ if (current == active)
+ current = 0;
}
return;
}
// Now both inpipe and outpipe are detached. Remove them from the lists.
- if (index < active)
+ if (index < active) {
active--;
+ if (current == active)
+ current = 0;
+ }
+
in_pipes.erase (index);
out_pipes.erase (index);
}
@@ -103,13 +109,19 @@ void zmq::rep_t::xdetach_outpipe (class writer_t *pipe_)
active--;
in_pipes.swap (index, active);
out_pipes.swap (index, active);
+ if (current == active)
+ current = 0;
}
return;
}
// Now both inpipe and outpipe are detached. Remove them from the lists.
- if (out_pipes.index (pipe_) < active)
+ if (out_pipes.index (pipe_) < active) {
active--;
+ if (current == active)
+ current = 0;
+ }
+
in_pipes.erase (index);
out_pipes.erase (index);
}