Commit 5c54bc35 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #573 from shripchenko/master

another iteration on ZMQ_PROBE_ROUTER
parents 6b8569d7 627190c8
...@@ -44,8 +44,8 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_) ...@@ -44,8 +44,8 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
int rc = probe_msg_.init (); int rc = probe_msg_.init ();
errno_assert (rc == 0); errno_assert (rc == 0);
int ok = pipe_->write (&probe_msg_); rc = pipe_->write (&probe_msg_);
zmq_assert (ok); // zmq_assert (rc) is not applicable here, since it is not a bug.
pipe_->flush (); pipe_->flush ();
rc = probe_msg_.close (); rc = probe_msg_.close ();
......
...@@ -59,6 +59,19 @@ void zmq::router_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_) ...@@ -59,6 +59,19 @@ void zmq::router_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
zmq_assert (pipe_); zmq_assert (pipe_);
if (probe_router) {
msg_t probe_msg_;
int rc = probe_msg_.init ();
errno_assert (rc == 0);
rc = pipe_->write (&probe_msg_);
// zmq_assert (rc) is not applicable here, since it is not a bug.
pipe_->flush ();
rc = probe_msg_.close ();
errno_assert (rc == 0);
}
bool identity_ok = identify_peer (pipe_); bool identity_ok = identify_peer (pipe_);
if (identity_ok) if (identity_ok)
fq.attach (pipe_); fq.attach (pipe_);
...@@ -391,22 +404,6 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_) ...@@ -391,22 +404,6 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_)
ok = outpipes.insert (outpipes_t::value_type (identity, outpipe)).second; ok = outpipes.insert (outpipes_t::value_type (identity, outpipe)).second;
zmq_assert (ok); zmq_assert (ok);
if (probe_router) {
msg_t probe_msg_;
int rc = probe_msg_.init ();
errno_assert (rc == 0);
ok = pipe_->write (&probe_msg_);
pipe_->flush ();
rc = probe_msg_.close ();
errno_assert (rc == 0);
// Ignore not probed peers
if (!ok)
return false;
}
return true; return true;
} }
......
...@@ -35,9 +35,7 @@ int main (void) ...@@ -35,9 +35,7 @@ int main (void)
assert (rc == 0); assert (rc == 0);
// Create client and connect to server, doing a probe // Create client and connect to server, doing a probe
void *client = zmq_socket (ctx, ZMQ_DEALER); void *client = zmq_socket (ctx, ZMQ_ROUTER);
// Trying this results in the first recv waiting forever
// void *client = zmq_socket (ctx, ZMQ_ROUTER);
assert (client); assert (client);
rc = zmq_setsockopt (client, ZMQ_IDENTITY, "X", 1); rc = zmq_setsockopt (client, ZMQ_IDENTITY, "X", 1);
assert (rc == 0); assert (rc == 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment