Commit a9679da7 authored by Pieter Hintjens's avatar Pieter Hintjens

Packaging on ZMQ_PROBE_ROUTER

- renamed to ZMQ_PROBE_ROUTER
parent 2344131d
...@@ -48,7 +48,7 @@ tests/test_disconnect_inproc ...@@ -48,7 +48,7 @@ tests/test_disconnect_inproc
tests/test_ctx_options tests/test_ctx_options
tests/test_iov tests/test_iov
tests/test_security tests/test_security
tests/test_router_probe tests/test_probe_router
src/platform.hpp* src/platform.hpp*
src/stamp-h1 src/stamp-h1
perf/local_lat perf/local_lat
......
...@@ -13,8 +13,8 @@ SYNOPSIS ...@@ -13,8 +13,8 @@ SYNOPSIS
*int zmq_setsockopt (void '*socket', int 'option_name', const void '*option_value', size_t 'option_len');* *int zmq_setsockopt (void '*socket', int 'option_name', const void '*option_value', size_t 'option_len');*
Caution: All options, with the exception of ZMQ_SUBSCRIBE, ZMQ_UNSUBSCRIBE, Caution: All options, with the exception of ZMQ_SUBSCRIBE, ZMQ_UNSUBSCRIBE,
ZMQ_LINGER, ZMQ_ROUTER_MANDATORY, ZMQ_PROBE, and ZMQ_XPUB_VERBOSE only take ZMQ_LINGER, ZMQ_ROUTER_MANDATORY, ZMQ_PROBE_ROUTER, and ZMQ_XPUB_VERBOSE
effect for subsequent socket bind/connects. only take effect for subsequent socket bind/connects.
DESCRIPTION DESCRIPTION
----------- -----------
...@@ -421,14 +421,14 @@ Default value:: 0 ...@@ -421,14 +421,14 @@ Default value:: 0
Applicable socket types:: ZMQ_ROUTER Applicable socket types:: ZMQ_ROUTER
ZMQ_PROBE: bootstrap connections to ROUTER sockets ZMQ_PROBE_ROUTER: bootstrap connections to ROUTER sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When set to 1, the socket will automatically send an empty message when a When set to 1, the socket will automatically send an empty message when a
new connection is made or accepted. You may set this on REQ, DEALER, or new connection is made or accepted. You may set this on REQ, DEALER, or
ROUTER sockets connected to a ROUTER socket. The application must filter ROUTER sockets connected to a ROUTER socket. The application must filter
such empty messages. The ZMQ_PROBE option in effect provides the ROUTER such empty messages. The ZMQ_PROBE_ROUTER option in effect provides the
application with an event signaling the arrival of a new peer. ROUTER application with an event signaling the arrival of a new peer.
NOTE: do not set this option on a socket that talks to any other socket NOTE: do not set this option on a socket that talks to any other socket
types: the results are undefined. types: the results are undefined.
...@@ -437,7 +437,7 @@ types: the results are undefined. ...@@ -437,7 +437,7 @@ types: the results are undefined.
Option value type:: int Option value type:: int
Option value unit:: 0, 1 Option value unit:: 0, 1
Default value:: 0 Default value:: 0
Applicable socket types:: ZMQ_ROUTER, ZMQ_DEALER, ZMQ_REP, ZMQ_REQ Applicable socket types:: ZMQ_ROUTER, ZMQ_DEALER, ZMQ_REQ
ZMQ_XPUB_VERBOSE: provide all subscription messages on XPUB sockets ZMQ_XPUB_VERBOSE: provide all subscription messages on XPUB sockets
......
...@@ -274,7 +274,7 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval); ...@@ -274,7 +274,7 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
#define ZMQ_CURVE_SERVER 47 #define ZMQ_CURVE_SERVER 47
#define ZMQ_CURVE_PUBLICKEY 48 #define ZMQ_CURVE_PUBLICKEY 48
#define ZMQ_CURVE_SERVERKEY 49 #define ZMQ_CURVE_SERVERKEY 49
#define ZMQ_PROBE 50 #define ZMQ_PROBE_ROUTER 50
/* Message options */ /* Message options */
#define ZMQ_MORE 1 #define ZMQ_MORE 1
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) : zmq::dealer_t::dealer_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
socket_base_t (parent_, tid_, sid_), socket_base_t (parent_, tid_, sid_),
probe_new_peers(false) probe_router (false)
{ {
options.type = ZMQ_DEALER; options.type = ZMQ_DEALER;
} }
...@@ -39,14 +39,12 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_) ...@@ -39,14 +39,12 @@ void zmq::dealer_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
zmq_assert (pipe_); zmq_assert (pipe_);
if (probe_new_peers) { if (probe_router) {
int rc, ok;
msg_t probe_msg_; msg_t probe_msg_;
int rc = probe_msg_.init ();
rc = probe_msg_.init ();
errno_assert (rc == 0); errno_assert (rc == 0);
ok = pipe_->write (&probe_msg_); int ok = pipe_->write (&probe_msg_);
zmq_assert (ok); zmq_assert (ok);
pipe_->flush (); pipe_->flush ();
...@@ -65,9 +63,9 @@ int zmq::dealer_t::xsetsockopt (int option_, const void *optval_, ...@@ -65,9 +63,9 @@ int zmq::dealer_t::xsetsockopt (int option_, const void *optval_,
int value = is_int? *((int *) optval_): 0; int value = is_int? *((int *) optval_): 0;
switch (option_) { switch (option_) {
case ZMQ_PROBE: case ZMQ_PROBE_ROUTER:
if (is_int && value >= 0) { if (is_int && value >= 0) {
probe_new_peers = value; probe_router = value;
return 0; return 0;
} }
break; break;
......
...@@ -62,8 +62,8 @@ namespace zmq ...@@ -62,8 +62,8 @@ namespace zmq
fq_t fq; fq_t fq;
lb_t lb; lb_t lb;
// if true, send an empty message to every connected peer // if true, send an empty message to every connected router peer
bool probe_new_peers; bool probe_router;
dealer_t (const dealer_t&); dealer_t (const dealer_t&);
const dealer_t &operator = (const dealer_t&); const dealer_t &operator = (const dealer_t&);
......
...@@ -32,9 +32,9 @@ zmq::router_t::router_t (class ctx_t *parent_, uint32_t tid_, int sid_) : ...@@ -32,9 +32,9 @@ zmq::router_t::router_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
current_out (NULL), current_out (NULL),
more_out (false), more_out (false),
next_peer_id (generate_random ()), next_peer_id (generate_random ()),
mandatory(false), mandatory (false),
raw_sock(false), raw_sock (false),
probe_new_peers(false) probe_router (false)
{ {
options.type = ZMQ_ROUTER; options.type = ZMQ_ROUTER;
options.recv_identity = true; options.recv_identity = true;
...@@ -91,9 +91,9 @@ int zmq::router_t::xsetsockopt (int option_, const void *optval_, ...@@ -91,9 +91,9 @@ int zmq::router_t::xsetsockopt (int option_, const void *optval_,
} }
break; break;
case ZMQ_PROBE: case ZMQ_PROBE_ROUTER:
if (is_int && value >= 0) { if (is_int && value >= 0) {
probe_new_peers = value; probe_router = value;
return 0; return 0;
} }
break; break;
...@@ -391,11 +391,9 @@ bool zmq::router_t::identify_peer (pipe_t *pipe_) ...@@ -391,11 +391,9 @@ 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_new_peers) { if (probe_router) {
int rc;
msg_t probe_msg_; msg_t probe_msg_;
int rc = probe_msg_.init ();
rc = probe_msg_.init ();
errno_assert (rc == 0); errno_assert (rc == 0);
ok = pipe_->write (&probe_msg_); ok = pipe_->write (&probe_msg_);
......
...@@ -112,8 +112,8 @@ namespace zmq ...@@ -112,8 +112,8 @@ namespace zmq
bool mandatory; bool mandatory;
bool raw_sock; bool raw_sock;
// if true, send an empty message to every connected peer to solve 'who will write first?' auto discovery problem // if true, send an empty message to every connected router peer
bool probe_new_peers; bool probe_router;
router_t (const router_t&); router_t (const router_t&);
const router_t &operator = (const router_t&); const router_t &operator = (const router_t&);
......
...@@ -18,7 +18,7 @@ noinst_PROGRAMS = test_pair_inproc \ ...@@ -18,7 +18,7 @@ noinst_PROGRAMS = test_pair_inproc \
test_term_endpoint \ test_term_endpoint \
test_monitor \ test_monitor \
test_router_mandatory \ test_router_mandatory \
test_router_probe \ test_probe_router \
test_raw_sock \ test_raw_sock \
test_disconnect_inproc \ test_disconnect_inproc \
test_ctx_options \ test_ctx_options \
...@@ -47,7 +47,7 @@ test_last_endpoint_SOURCES = test_last_endpoint.cpp ...@@ -47,7 +47,7 @@ test_last_endpoint_SOURCES = test_last_endpoint.cpp
test_term_endpoint_SOURCES = test_term_endpoint.cpp test_term_endpoint_SOURCES = test_term_endpoint.cpp
test_monitor_SOURCES = test_monitor.cpp test_monitor_SOURCES = test_monitor.cpp
test_router_mandatory_SOURCES = test_router_mandatory.cpp test_router_mandatory_SOURCES = test_router_mandatory.cpp
test_router_probe_SOURCES = test_router_probe.cpp test_probe_router_SOURCES = test_probe_router.cpp
test_raw_sock_SOURCES = test_raw_sock.cpp test_raw_sock_SOURCES = test_raw_sock.cpp
test_disconnect_inproc_SOURCES = test_disconnect_inproc.cpp test_disconnect_inproc_SOURCES = test_disconnect_inproc.cpp
test_ctx_options_SOURCES = test_ctx_options.cpp test_ctx_options_SOURCES = test_ctx_options.cpp
......
...@@ -36,11 +36,13 @@ int main (void) ...@@ -36,11 +36,13 @@ int main (void)
// 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_DEALER);
// 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);
int probe = 1; int probe = 1;
rc = zmq_setsockopt (client, ZMQ_PROBE, &probe, sizeof (probe)); rc = zmq_setsockopt (client, ZMQ_PROBE_ROUTER, &probe, sizeof (probe));
assert (rc == 0); assert (rc == 0);
rc = zmq_connect (client, "tcp://localhost:5560"); rc = zmq_connect (client, "tcp://localhost:5560");
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