Commit 7470c00d authored by Pieter Hintjens's avatar Pieter Hintjens

Problem: ZMQ_TCP_RECV_BUFFER/SEND_BUFFER are redundant

These options are confusing and redundant. Their names suggest
they apply to the tcp:// transport, yet they are used for all
stream protocols. The methods zmq::set_tcp_receive_buffer and
zmq::set_tcp_send_buffer don't use these values at all, they use
ZMQ_SNDBUF and ZMQ_RCVBUF.

Solution: merge these new options into ZMQ_SNDBUF and ZMQ_RCVBUF.

This means defaulting these two options to 8192, and removing the
new options. We now have ZMQ_SNDBUF and ZMQ_RCVBUF being used both
for TCP socket control, and for input/output buffering.

Note: the default for SNDBUF and RCVBUF are otherwise 4096.
parent 884c7f78
...@@ -498,6 +498,7 @@ documentation for the 'SO_RCVBUF' socket option. ...@@ -498,6 +498,7 @@ documentation for the 'SO_RCVBUF' socket option.
[horizontal] [horizontal]
Option value type:: int Option value type:: int
Option value unit:: bytes Option value unit:: bytes
Default value:: 8192
Applicable socket types:: all Applicable socket types:: all
...@@ -612,6 +613,7 @@ documentation for the 'SO_SNDBUF' socket option. ...@@ -612,6 +613,7 @@ documentation for the 'SO_SNDBUF' socket option.
[horizontal] [horizontal]
Option value type:: int Option value type:: int
Option value unit:: bytes Option value unit:: bytes
Default value:: 8192
Applicable socket types:: all Applicable socket types:: all
...@@ -763,31 +765,6 @@ Option value unit:: N/A ...@@ -763,31 +765,6 @@ Option value unit:: N/A
Default value:: not set Default value:: not set
Applicable socket types:: all, when using TCP transport Applicable socket types:: all, when using TCP transport
ZMQ_TCP_RECV_BUFFER: Size of the TCP receive buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_TCP_RECV_BUFFER' specifies the maximum number of bytes which can
be received by an individual syscall to receive data from the TCP socket.
The default value is 8192.
[horizontal]
Option value type:: int
Option value unit:: >0
Default value:: 8192
Applicable socket types:: all, when using TCP transport
ZMQ_TCP_SEND_BUFFER: Size of the TCP receive buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_TCP_SEND_BUFFER' specifies the maximum number of bytes which can
be sent by an individual syscall to transmit data to the TCP socket.
The default value is 8192.
[horizontal]
Option value type:: int
Option value unit:: >0
Default value:: 8192
Applicable socket types:: all, when using TCP transport
ZMQ_VMCI_BUFFER_SIZE: Retrieve buffer size of the VMCI socket ZMQ_VMCI_BUFFER_SIZE: Retrieve buffer size of the VMCI socket
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
...@@ -1102,31 +1102,6 @@ Option value unit:: boolean ...@@ -1102,31 +1102,6 @@ Option value unit:: boolean
Default value:: 1 (true) Default value:: 1 (true)
Applicable socket types:: all, when using TCP transports. Applicable socket types:: all, when using TCP transports.
ZMQ_TCP_RECV_BUFFER: Size of the TCP receive buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_TCP_RECV_BUFFER' specifies the maximum number of bytes which can
be received by an individual syscall to receive data from the TCP socket.
The default value is 8192.
[horizontal]
Option value type:: int
Option value unit:: >0
Default value:: 8192
Applicable socket types:: all, when using TCP transport
ZMQ_TCP_SEND_BUFFER: Size of the TCP receive buffer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'ZMQ_TCP_SEND_BUFFER' specifies the maximum number of bytes which can
be sent by an individual syscall to transmit data to the TCP socket.
The default value is 8192.
[horizontal]
Option value type:: int
Option value unit:: >0
Default value:: 8192
Applicable socket types:: all, when using TCP transport
ZMQ_VMCI_BUFFER_SIZE: Set buffer size of the VMCI socket ZMQ_VMCI_BUFFER_SIZE: Set buffer size of the VMCI socket
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
...@@ -339,8 +339,6 @@ ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg); ...@@ -339,8 +339,6 @@ ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg);
#define ZMQ_CONNECT_TIMEOUT 79 #define ZMQ_CONNECT_TIMEOUT 79
#define ZMQ_TCP_MAXRT 80 #define ZMQ_TCP_MAXRT 80
#define ZMQ_THREAD_SAFE 81 #define ZMQ_THREAD_SAFE 81
#define ZMQ_TCP_RECV_BUFFER 82
#define ZMQ_TCP_SEND_BUFFER 83
#define ZMQ_MULTICAST_MAXTPDU 84 #define ZMQ_MULTICAST_MAXTPDU 84
#define ZMQ_VMCI_BUFFER_SIZE 85 #define ZMQ_VMCI_BUFFER_SIZE 85
#define ZMQ_VMCI_BUFFER_MIN_SIZE 86 #define ZMQ_VMCI_BUFFER_MIN_SIZE 86
......
...@@ -42,8 +42,8 @@ zmq::options_t::options_t () : ...@@ -42,8 +42,8 @@ zmq::options_t::options_t () :
recovery_ivl (10000), recovery_ivl (10000),
multicast_hops (1), multicast_hops (1),
multicast_maxtpdu (1500), multicast_maxtpdu (1500),
sndbuf (-1), sndbuf (8192),
rcvbuf (-1), rcvbuf (8192),
tos (0), tos (0),
type (-1), type (-1),
linger (-1), linger (-1),
...@@ -66,8 +66,6 @@ zmq::options_t::options_t () : ...@@ -66,8 +66,6 @@ zmq::options_t::options_t () :
tcp_keepalive_cnt (-1), tcp_keepalive_cnt (-1),
tcp_keepalive_idle (-1), tcp_keepalive_idle (-1),
tcp_keepalive_intvl (-1), tcp_keepalive_intvl (-1),
tcp_recv_buffer_size (8192),
tcp_send_buffer_size (8192),
mechanism (ZMQ_NULL), mechanism (ZMQ_NULL),
as_server (0), as_server (0),
gss_plaintext (false), gss_plaintext (false),
...@@ -298,20 +296,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, ...@@ -298,20 +296,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
} }
break; break;
case ZMQ_TCP_RECV_BUFFER:
if (is_int && (value > 0) ) {
tcp_recv_buffer_size = static_cast<unsigned int>(value);
return 0;
}
break;
case ZMQ_TCP_SEND_BUFFER:
if (is_int && (value > 0) ) {
tcp_send_buffer_size = static_cast<unsigned int>(value);
return 0;
}
break;
case ZMQ_IMMEDIATE: case ZMQ_IMMEDIATE:
if (is_int && (value == 0 || value == 1)) { if (is_int && (value == 0 || value == 1)) {
immediate = value; immediate = value;
...@@ -866,20 +850,6 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) ...@@ -866,20 +850,6 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
} }
break; break;
case ZMQ_TCP_SEND_BUFFER:
if (is_int) {
*value = tcp_send_buffer_size;
return 0;
}
break;
case ZMQ_TCP_RECV_BUFFER:
if (is_int) {
*value = tcp_recv_buffer_size;
return 0;
}
break;
case ZMQ_MECHANISM: case ZMQ_MECHANISM:
if (is_int) { if (is_int) {
*value = mechanism; *value = mechanism;
......
...@@ -160,10 +160,6 @@ namespace zmq ...@@ -160,10 +160,6 @@ namespace zmq
typedef std::vector <tcp_address_mask_t> tcp_accept_filters_t; typedef std::vector <tcp_address_mask_t> tcp_accept_filters_t;
tcp_accept_filters_t tcp_accept_filters; tcp_accept_filters_t tcp_accept_filters;
// TCP buffer sizes
unsigned int tcp_recv_buffer_size;
unsigned int tcp_send_buffer_size;
// IPC accept() filters // IPC accept() filters
# if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED # if defined ZMQ_HAVE_SO_PEERCRED || defined ZMQ_HAVE_LOCAL_PEERCRED
bool zap_ipc_creds; bool zap_ipc_creds;
......
...@@ -203,10 +203,10 @@ void zmq::stream_engine_t::plug (io_thread_t *io_thread_, ...@@ -203,10 +203,10 @@ void zmq::stream_engine_t::plug (io_thread_t *io_thread_,
if (options.raw_socket) { if (options.raw_socket) {
// no handshaking for raw sock, instantiate raw encoder and decoders // no handshaking for raw sock, instantiate raw encoder and decoders
encoder = new (std::nothrow) raw_encoder_t (options.tcp_send_buffer_size); encoder = new (std::nothrow) raw_encoder_t (options.sndbuf);
alloc_assert (encoder); alloc_assert (encoder);
decoder = new (std::nothrow) raw_decoder_t (options.tcp_recv_buffer_size); decoder = new (std::nothrow) raw_decoder_t (options.rcvbuf);
alloc_assert (decoder); alloc_assert (decoder);
// disable handshaking for raw socket // disable handshaking for raw socket
...@@ -385,12 +385,12 @@ void zmq::stream_engine_t::out_event () ...@@ -385,12 +385,12 @@ void zmq::stream_engine_t::out_event ()
outpos = NULL; outpos = NULL;
outsize = encoder->encode (&outpos, 0); outsize = encoder->encode (&outpos, 0);
while (outsize < options.tcp_send_buffer_size) { while (outsize < (size_t) options.sndbuf) {
if ((this->*next_msg) (&tx_msg) == -1) if ((this->*next_msg) (&tx_msg) == -1)
break; break;
encoder->load_msg (&tx_msg); encoder->load_msg (&tx_msg);
unsigned char *bufptr = outpos + outsize; unsigned char *bufptr = outpos + outsize;
size_t n = encoder->encode (&bufptr, options.tcp_send_buffer_size - outsize); size_t n = encoder->encode (&bufptr, options.sndbuf - outsize);
zmq_assert (n > 0); zmq_assert (n > 0);
if (outpos == NULL) if (outpos == NULL)
outpos = bufptr; outpos = bufptr;
...@@ -587,10 +587,10 @@ bool zmq::stream_engine_t::handshake () ...@@ -587,10 +587,10 @@ bool zmq::stream_engine_t::handshake ()
return false; return false;
} }
encoder = new (std::nothrow) v1_encoder_t (options.tcp_send_buffer_size); encoder = new (std::nothrow) v1_encoder_t (options.sndbuf);
alloc_assert (encoder); alloc_assert (encoder);
decoder = new (std::nothrow) v1_decoder_t (options.tcp_recv_buffer_size, options.maxmsgsize); decoder = new (std::nothrow) v1_decoder_t (options.rcvbuf, options.maxmsgsize);
alloc_assert (decoder); alloc_assert (decoder);
// We have already sent the message header. // We have already sent the message header.
...@@ -635,11 +635,11 @@ bool zmq::stream_engine_t::handshake () ...@@ -635,11 +635,11 @@ bool zmq::stream_engine_t::handshake ()
} }
encoder = new (std::nothrow) v1_encoder_t ( encoder = new (std::nothrow) v1_encoder_t (
options.tcp_send_buffer_size); options.sndbuf);
alloc_assert (encoder); alloc_assert (encoder);
decoder = new (std::nothrow) v1_decoder_t ( decoder = new (std::nothrow) v1_decoder_t (
options.tcp_recv_buffer_size, options.maxmsgsize); options.rcvbuf, options.maxmsgsize);
alloc_assert (decoder); alloc_assert (decoder);
} }
else else
...@@ -650,19 +650,19 @@ bool zmq::stream_engine_t::handshake () ...@@ -650,19 +650,19 @@ bool zmq::stream_engine_t::handshake ()
return false; return false;
} }
encoder = new (std::nothrow) v2_encoder_t (options.tcp_send_buffer_size); encoder = new (std::nothrow) v2_encoder_t (options.sndbuf);
alloc_assert (encoder); alloc_assert (encoder);
decoder = new (std::nothrow) v2_decoder_t ( decoder = new (std::nothrow) v2_decoder_t (
options.tcp_recv_buffer_size, options.maxmsgsize); options.rcvbuf, options.maxmsgsize);
alloc_assert (decoder); alloc_assert (decoder);
} }
else { else {
encoder = new (std::nothrow) v2_encoder_t (options.tcp_send_buffer_size); encoder = new (std::nothrow) v2_encoder_t (options.sndbuf);
alloc_assert (encoder); alloc_assert (encoder);
decoder = new (std::nothrow) v2_decoder_t ( decoder = new (std::nothrow) v2_decoder_t (
options.tcp_recv_buffer_size, options.maxmsgsize); options.rcvbuf, options.maxmsgsize);
alloc_assert (decoder); alloc_assert (decoder);
if (options.mechanism == ZMQ_NULL if (options.mechanism == ZMQ_NULL
......
...@@ -84,7 +84,7 @@ void zmq::set_tcp_send_buffer (fd_t sockfd_, int bufsize_) ...@@ -84,7 +84,7 @@ void zmq::set_tcp_send_buffer (fd_t sockfd_, int bufsize_)
void zmq::set_tcp_receive_buffer (fd_t sockfd_, int bufsize_) void zmq::set_tcp_receive_buffer (fd_t sockfd_, int bufsize_)
{ {
const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_RCVBUF, const int rc = setsockopt (sockfd_, SOL_SOCKET, SO_RCVBUF,
(char*) &bufsize_, sizeof bufsize_); (char *) &bufsize_, sizeof bufsize_);
#ifdef ZMQ_HAVE_WINDOWS #ifdef ZMQ_HAVE_WINDOWS
wsa_assert (rc != SOCKET_ERROR); wsa_assert (rc != SOCKET_ERROR);
#else #else
......
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