summaryrefslogtreecommitdiff
path: root/src/rep.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.commkdir>2009-11-14 18:57:04 +0100
committerMartin Sustrik <sustrik@fastmq.commkdir>2009-11-14 18:57:04 +0100
commit26ca5ed8c62f8a88a32106a5c9e003712f4ca655 (patch)
tree23fa018f7a20f212d2af1cda93e7f43353970925 /src/rep.cpp
parent84585a9561b5e3bd39baa8d49b889455362334ea (diff)
Fixing concurrency issue in rep.cpp resulting in broken connections with multiple requesters under heavy load.
Diffstat (limited to 'src/rep.cpp')
-rw-r--r--src/rep.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/rep.cpp b/src/rep.cpp
index e8a9e39..7599cb5 100644
--- a/src/rep.cpp
+++ b/src/rep.cpp
@@ -178,14 +178,15 @@ int zmq::rep_t::xrecv (zmq_msg_t *msg_, int flags_)
// Round-robin over the pipes to get next message.
for (int count = active; count != 0; count--) {
bool fetched = in_pipes [current]->read (msg_);
- current++;
- if (current >= active)
- current = 0;
if (fetched) {
reply_pipe = out_pipes [current];
waiting_for_reply = true;
- return 0;
}
+ current++;
+ if (current >= active)
+ current = 0;
+ if (fetched)
+ return 0;
}
// No message is available. Initialise the output parameter