The previous code to block the socket from receiving on that pipe during a disconnect was vulnerable to a race condition. This code calls with the terminate functions of both ends of the pipe - I believe this should be safer. This required storing a pointer to the socket end of the pipe

This commit is contained in:
Ian Barber
2012-06-05 21:44:23 +01:00
parent 5008f385ba
commit 336f72720a
2 changed files with 7 additions and 2 deletions

View File

@@ -308,6 +308,9 @@ void zmq::session_base_t::process_attach (i_engine *engine_)
// Ask socket to plug into the remote end of the pipe.
send_bind (socket, pipes [1]);
// Store the outpipe for disconnect situations
outpipe = pipes [1];
}
// Plug in the engine.
@@ -411,8 +414,7 @@ void zmq::session_base_t::detached ()
if (pipe && options.delay_attach_on_connect == 1
&& addr->protocol != "pgm" && addr->protocol != "epgm") {
pipe->terminate (false);
socket->terminated (pipe);
pipe = NULL;
outpipe->terminate (false);
}
}