Renamed ZMQ_DELAY_ATTACH_ON_CONNECT_COULD_THIS_BE_ANY_LONGER to ZMQ_IMMEDIATE

This commit is contained in:
Pieter Hintjens 2013-03-12 16:11:19 +01:00
parent 12c7db8c42
commit 8358d4e832
6 changed files with 23 additions and 20 deletions

View File

@ -360,7 +360,7 @@ Applicable socket types:: all, when using TCP transports.
ZMQ_IPV4ONLY: Use IPv4-only on socket
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Set the IPv4-only ootion for the socket. This option is deprecated.
Set the IPv4-only option for the socket. This option is deprecated.
Please use the ZMQ_IPV6 option.
[horizontal]
@ -370,12 +370,15 @@ Default value:: 1 (true)
Applicable socket types:: all, when using TCP transports.
ZMQ_DELAY_ATTACH_ON_CONNECT: Accept messages only when connections are made
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ZMQ_IMMEDIATE: Queue messages only to completed connections
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If set to `1`, will delay the attachment of a pipe on connect until the underlying
connection has completed. This will cause the socket to block if there are no other
connections, but will prevent queues from filling on pipes awaiting connection.
By default queues will fill on outgoing connections even if the connection has
not completed. This can lead to "lost" messages on sockets with round-robin
routing (REQ, PUSH, DEALER). If this option is set to `1`, messages shall be
queued only to completed connections. This will cause the socket to block if
there are no other connections, but will prevent queues from filling on pipes
awaiting connection.
[horizontal]
Option value type:: int

View File

@ -249,12 +249,11 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
#define ZMQ_TCP_KEEPALIVE_IDLE 36
#define ZMQ_TCP_KEEPALIVE_INTVL 37
#define ZMQ_TCP_ACCEPT_FILTER 38
#define ZMQ_DELAY_ATTACH_ON_CONNECT 39
#define ZMQ_IMMEDIATE 39
#define ZMQ_XPUB_VERBOSE 40
#define ZMQ_ROUTER_RAW 41
#define ZMQ_IPV6 42
/* Message options */
#define ZMQ_MORE 1
@ -263,9 +262,10 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
#define ZMQ_SNDMORE 2
/* Deprecated aliases */
#define ZMQ_NOBLOCK ZMQ_DONTWAIT
#define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY
#define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY
#define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE
#define ZMQ_NOBLOCK ZMQ_DONTWAIT
#define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY
#define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY
/******************************************************************************/
/* 0MQ socket events and monitoring */

View File

@ -41,7 +41,7 @@ zmq::options_t::options_t () :
rcvtimeo (-1),
sndtimeo (-1),
ipv6 (0),
delay_attach_on_connect (0),
immediate (0),
delay_on_close (true),
delay_on_disconnect (true),
filter (false),
@ -224,9 +224,9 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
valid = false;
break;
case ZMQ_DELAY_ATTACH_ON_CONNECT:
case ZMQ_IMMEDIATE:
if (is_int && (value == 0 || value == 1))
delay_attach_on_connect = value;
immediate = value;
else
valid = false;
break;
@ -435,12 +435,12 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
*optvallen_ = sizeof (int);
return 0;
case ZMQ_DELAY_ATTACH_ON_CONNECT:
case ZMQ_IMMEDIATE:
if (*optvallen_ < sizeof (int)) {
errno = EINVAL;
return -1;
}
*((int*) optval_) = delay_attach_on_connect;
*((int*) optval_) = immediate;
*optvallen_ = sizeof (int);
return 0;

View File

@ -93,7 +93,7 @@ namespace zmq
// If 1, connecting pipes are not attached immediately, meaning a send()
// on a socket with only connecting pipes would block
int delay_attach_on_connect;
int immediate;
// If true, session reads all the pending messages from the pipe and
// sends them to the network when socket is closed.

View File

@ -409,7 +409,7 @@ void zmq::session_base_t::detached ()
// For delayed connect situations, terminate the pipe
// and reestablish later on
if (pipe && options.delay_attach_on_connect == 1
if (pipe && options.immediate == 1
&& addr->protocol != "pgm" && addr->protocol != "epgm") {
pipe->hiccup ();
pipe->terminate (false);

View File

@ -535,7 +535,7 @@ int zmq::socket_base_t::connect (const char *addr_)
// sent to this pipe.
bool icanhasall = protocol == "pgm" || protocol == "epgm";
if (options.delay_attach_on_connect != 1 || icanhasall) {
if (options.immediate != 1 || icanhasall) {
// Create a bi-directional pipe.
object_t *parents [2] = {this, session};
pipe_t *new_pipes [2] = {NULL, NULL};
@ -996,7 +996,7 @@ void zmq::socket_base_t::write_activated (pipe_t *pipe_)
void zmq::socket_base_t::hiccuped (pipe_t *pipe_)
{
if (options.delay_attach_on_connect == 1)
if (options.immediate == 1)
pipe_->terminate (false);
else
// Notify derived sockets of the hiccup