From e5d4cd39e1c9949b549055f816d60dd35bfacdec Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Mon, 2 May 2011 19:26:30 +0200 Subject: Yet one more fix related to PUB socket and multipart messages This patch fixes the activation of the pipes, when they pass from passive state directly to active. Signed-off-by: Martin Sustrik --- src/dist.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/dist.cpp') diff --git a/src/dist.cpp b/src/dist.cpp index 9201294..c15ab6b 100644 --- a/src/dist.cpp +++ b/src/dist.cpp @@ -90,17 +90,15 @@ void zmq::dist_t::terminated (writer_t *pipe_) void zmq::dist_t::activated (writer_t *pipe_) { - // If we are in the middle of sending a message, we'll add the pipe - // into the list of eligible pipes. Otherwise we add it to the list - // of active pipes. - if (more) { - pipes.swap (pipes.index (pipe_), eligible); - eligible++; - } - else { - pipes.swap (pipes.index (pipe_), active); + // Move the pipe from passive to eligible state. + pipes.swap (pipes.index (pipe_), eligible); + eligible++; + + // If there's no message being sent at the moment, move it to + // the active state. + if (!more) { + pipes.swap (eligible - 1, active); active++; - eligible++; } } -- cgit v1.2.3