race condition in inproc transport shutdown fixed

This commit is contained in:
Martin Sustrik
2009-11-21 21:30:09 +01:00
parent 64634605b3
commit c41daca3da
6 changed files with 29 additions and 12 deletions

View File

@@ -158,10 +158,10 @@ int zmq::socket_base_t::connect (const char *addr_)
out_pipe ? &out_pipe->writer : NULL);
// Attach the pipes to the peer socket. Note that peer's seqnum
// was incremented in find_endpoint function. When this command
// is delivered, peer will consider the seqnum to be processed.
// was incremented in find_endpoint function. The callee is notified
// about the fact via the last parameter.
send_bind (peer, out_pipe ? &out_pipe->reader : NULL,
in_pipe ? &in_pipe->writer : NULL);
in_pipe ? &in_pipe->writer : NULL, true);
return 0;
}
@@ -509,8 +509,16 @@ void zmq::socket_base_t::process_own (owned_t *object_)
io_objects.insert (object_);
}
void zmq::socket_base_t::process_bind (reader_t *in_pipe_, writer_t *out_pipe_)
void zmq::socket_base_t::process_bind (reader_t *in_pipe_, writer_t *out_pipe_,
bool adjust_seqnum_)
{
// In case of inproc transport, the seqnum should catch up here.
// For other transports the seqnum modification can be optimised out
// because final handshaking between the socket and the session ensures
// that no 'bind' command will be left unprocessed.
if (adjust_seqnum_)
processed_seqnum++;
attach_pipes (in_pipe_, out_pipe_);
}