0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-01 02:27:49 +08:00

Fix possible lockups when reading from ZMQ_REP sockets

This commit is contained in:
Martin Hurton 2010-03-03 00:08:11 +01:00
parent 157a66fc42
commit 708298d798

View File

@ -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);
}