0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-06 03:19:00 +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--; active--;
in_pipes.swap (index, active); in_pipes.swap (index, active);
out_pipes.swap (index, active); out_pipes.swap (index, active);
if (current == active)
current = 0;
} }
return; return;
} }
// Now both inpipe and outpipe are detached. Remove them from the lists. // Now both inpipe and outpipe are detached. Remove them from the lists.
if (index < active) if (index < active) {
active--; active--;
if (current == active)
current = 0;
}
in_pipes.erase (index); in_pipes.erase (index);
out_pipes.erase (index); out_pipes.erase (index);
} }
@ -103,13 +109,19 @@ void zmq::rep_t::xdetach_outpipe (class writer_t *pipe_)
active--; active--;
in_pipes.swap (index, active); in_pipes.swap (index, active);
out_pipes.swap (index, active); out_pipes.swap (index, active);
if (current == active)
current = 0;
} }
return; return;
} }
// Now both inpipe and outpipe are detached. Remove them from the lists. // 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--; active--;
if (current == active)
current = 0;
}
in_pipes.erase (index); in_pipes.erase (index);
out_pipes.erase (index); out_pipes.erase (index);
} }