mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-29 12:18:04 +01:00
Merge pull request #1055 from hurtonm/master
Fix race condition in connecting inproc sockets
This commit is contained in:
16
src/ctx.cpp
16
src/ctx.cpp
@@ -445,6 +445,14 @@ void zmq::ctx_t::connect_inproc_sockets (zmq::socket_base_t *bind_socket_,
|
|||||||
bind_socket_->inc_seqnum();
|
bind_socket_->inc_seqnum();
|
||||||
pending_connection_.bind_pipe->set_tid(bind_socket_->get_tid());
|
pending_connection_.bind_pipe->set_tid(bind_socket_->get_tid());
|
||||||
|
|
||||||
|
if (!bind_options.recv_identity) {
|
||||||
|
msg_t msg;
|
||||||
|
const bool ok = pending_connection_.bind_pipe->read (&msg);
|
||||||
|
zmq_assert (ok);
|
||||||
|
const int rc = msg.close ();
|
||||||
|
errno_assert (rc == 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (side_ == bind_side) {
|
if (side_ == bind_side) {
|
||||||
command_t cmd;
|
command_t cmd;
|
||||||
cmd.type = command_t::bind;
|
cmd.type = command_t::bind;
|
||||||
@@ -474,14 +482,6 @@ void zmq::ctx_t::connect_inproc_sockets (zmq::socket_base_t *bind_socket_,
|
|||||||
pending_connection_.connect_pipe->set_hwms(hwms [1], hwms [0]);
|
pending_connection_.connect_pipe->set_hwms(hwms [1], hwms [0]);
|
||||||
pending_connection_.bind_pipe->set_hwms(hwms [0], hwms [1]);
|
pending_connection_.bind_pipe->set_hwms(hwms [0], hwms [1]);
|
||||||
|
|
||||||
if (!bind_options.recv_identity) {
|
|
||||||
msg_t msg;
|
|
||||||
const bool ok = pending_connection_.bind_pipe->read (&msg);
|
|
||||||
zmq_assert (ok);
|
|
||||||
const int rc = msg.close ();
|
|
||||||
errno_assert (rc == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pending_connection_.endpoint.options.recv_identity) {
|
if (pending_connection_.endpoint.options.recv_identity) {
|
||||||
msg_t id;
|
msg_t id;
|
||||||
int rc = id.init_size (bind_options.identity_size);
|
int rc = id.init_size (bind_options.identity_size);
|
||||||
|
|||||||
Reference in New Issue
Block a user