mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-30 13:47:13 +01:00
two races fixed in session creation
This commit is contained in:
@@ -153,14 +153,18 @@ void zmq::zmq_init_t::finalise_initialisation ()
|
|||||||
zmq_assert (socket);
|
zmq_assert (socket);
|
||||||
|
|
||||||
// We have no associated session. If the peer has no identity we'll
|
// We have no associated session. If the peer has no identity we'll
|
||||||
// create a transient session for the connection.
|
// create a transient session for the connection. Note that
|
||||||
|
// seqnum is incremented to account for attach command before the
|
||||||
|
// session is launched. That way we are sure it won't terminate before
|
||||||
|
// being attached.
|
||||||
if (peer_identity [0] == 0) {
|
if (peer_identity [0] == 0) {
|
||||||
session = new (std::nothrow) transient_session_t (io_thread,
|
session = new (std::nothrow) transient_session_t (io_thread,
|
||||||
socket, options);
|
socket, options);
|
||||||
zmq_assert (session);
|
zmq_assert (session);
|
||||||
|
session->inc_seqnum ();
|
||||||
launch_sibling (session);
|
launch_sibling (session);
|
||||||
engine->unplug ();
|
engine->unplug ();
|
||||||
send_attach (session, engine, peer_identity, true);
|
send_attach (session, engine, peer_identity, false);
|
||||||
engine = NULL;
|
engine = NULL;
|
||||||
terminate ();
|
terminate ();
|
||||||
return;
|
return;
|
||||||
@@ -179,13 +183,17 @@ void zmq::zmq_init_t::finalise_initialisation ()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's no such named session. We have to create one.
|
// There's no such named session. We have to create one. Note that
|
||||||
|
// seqnum is incremented to account for attach command before the
|
||||||
|
// session is launched. That way we are sure it won't terminate before
|
||||||
|
// being attached.
|
||||||
session = new (std::nothrow) named_session_t (io_thread, socket,
|
session = new (std::nothrow) named_session_t (io_thread, socket,
|
||||||
options, peer_identity);
|
options, peer_identity);
|
||||||
zmq_assert (session);
|
zmq_assert (session);
|
||||||
|
session->inc_seqnum ();
|
||||||
launch_sibling (session);
|
launch_sibling (session);
|
||||||
engine->unplug ();
|
engine->unplug ();
|
||||||
send_attach (session, engine, peer_identity, true);
|
send_attach (session, engine, peer_identity, false);
|
||||||
engine = NULL;
|
engine = NULL;
|
||||||
terminate ();
|
terminate ();
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user