0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-15 10:18:01 +08:00

Fix a race (to crash) when a message is sent as the last connection is lost.

Active is reduced in the zmq internal thread in terminated, potentially to zero.
If the user thread is in send() between lines 109 and 116, then the old code "(current+1) % active" is a divide by 0 - and crashes the program.
This commit is contained in:
daveab 2014-04-25 16:14:16 +01:00
parent 6077e52425
commit 00e5b37420

View File

@ -113,7 +113,8 @@ int zmq::lb_t::send (msg_t *msg_, int flags_)
more = msg_->flags () & msg_t::more? true: false;
if (!more) {
pipes [current]->flush ();
current = (current + 1) % active;
if (++current >= active)
current = 0;
}
// Detach the message from the data buffer.