mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 19:52:00 +01:00
ZMQ_SNDBUF and ZMQ_RCVBUF type changed to int
This mimics POSIX specification. Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
@@ -159,7 +159,7 @@ in effect. For details refer to your operating system documentation for the
|
|||||||
'SO_SNDBUF' socket option.
|
'SO_SNDBUF' socket option.
|
||||||
|
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Option value type:: uint64_t
|
Option value type:: int
|
||||||
Option value unit:: bytes
|
Option value unit:: bytes
|
||||||
Default value:: 0
|
Default value:: 0
|
||||||
Applicable socket types:: all
|
Applicable socket types:: all
|
||||||
@@ -173,7 +173,7 @@ in effect. For details refer to your operating system documentation for the
|
|||||||
'SO_RCVBUF' socket option.
|
'SO_RCVBUF' socket option.
|
||||||
|
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Option value type:: uint64_t
|
Option value type:: int
|
||||||
Option value unit:: bytes
|
Option value unit:: bytes
|
||||||
Default value:: 0
|
Default value:: 0
|
||||||
Applicable socket types:: all
|
Applicable socket types:: all
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ the OS default unchanged. For details please refer to your operating system
|
|||||||
documentation for the 'SO_SNDBUF' socket option.
|
documentation for the 'SO_SNDBUF' socket option.
|
||||||
|
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Option value type:: uint64_t
|
Option value type:: int
|
||||||
Option value unit:: bytes
|
Option value unit:: bytes
|
||||||
Default value:: 0
|
Default value:: 0
|
||||||
Applicable socket types:: all
|
Applicable socket types:: all
|
||||||
@@ -178,7 +178,7 @@ OS default unchanged. For details refer to your operating system documentation
|
|||||||
for the 'SO_RCVBUF' socket option.
|
for the 'SO_RCVBUF' socket option.
|
||||||
|
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Option value type:: uint64_t
|
Option value type:: int
|
||||||
Option value unit:: bytes
|
Option value unit:: bytes
|
||||||
Default value:: 0
|
Default value:: 0
|
||||||
Applicable socket types:: all
|
Applicable socket types:: all
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case ZMQ_RECOVERY_IVL:
|
case ZMQ_RECOVERY_IVL:
|
||||||
if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) {
|
if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -95,19 +95,19 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case ZMQ_SNDBUF:
|
case ZMQ_SNDBUF:
|
||||||
if (optvallen_ != sizeof (uint64_t)) {
|
if (optvallen_ != sizeof (int) || *((int*) optval_) < 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sndbuf = *((uint64_t*) optval_);
|
sndbuf = *((int*) optval_);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case ZMQ_RCVBUF:
|
case ZMQ_RCVBUF:
|
||||||
if (optvallen_ != sizeof (uint64_t)) {
|
if (optvallen_ != sizeof (int) || *((int*) optval_) < 0) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rcvbuf = *((uint64_t*) optval_);
|
rcvbuf = *((int*) optval_);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case ZMQ_LINGER:
|
case ZMQ_LINGER:
|
||||||
@@ -215,21 +215,21 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case ZMQ_SNDBUF:
|
case ZMQ_SNDBUF:
|
||||||
if (*optvallen_ < sizeof (uint64_t)) {
|
if (*optvallen_ < sizeof (int)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*((uint64_t*) optval_) = sndbuf;
|
*((int*) optval_) = sndbuf;
|
||||||
*optvallen_ = sizeof (uint64_t);
|
*optvallen_ = sizeof (int);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case ZMQ_RCVBUF:
|
case ZMQ_RCVBUF:
|
||||||
if (*optvallen_ < sizeof (uint64_t)) {
|
if (*optvallen_ < sizeof (int)) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*((uint64_t*) optval_) = rcvbuf;
|
*((int*) optval_) = rcvbuf;
|
||||||
*optvallen_ = sizeof (uint64_t);
|
*optvallen_ = sizeof (int);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case ZMQ_TYPE:
|
case ZMQ_TYPE:
|
||||||
|
|||||||
@@ -45,8 +45,9 @@ namespace zmq
|
|||||||
// Reliability time interval [ms]. Default 10 seconds.
|
// Reliability time interval [ms]. Default 10 seconds.
|
||||||
uint32_t recovery_ivl;
|
uint32_t recovery_ivl;
|
||||||
|
|
||||||
uint64_t sndbuf;
|
// SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets.
|
||||||
uint64_t rcvbuf;
|
int sndbuf;
|
||||||
|
int rcvbuf;
|
||||||
|
|
||||||
// Socket type.
|
// Socket type.
|
||||||
int type;
|
int type;
|
||||||
|
|||||||
@@ -35,22 +35,21 @@ zmq::tcp_socket_t::~tcp_socket_t ()
|
|||||||
close ();
|
close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tcp_socket_t::open (fd_t fd_, uint64_t sndbuf_, uint64_t rcvbuf_)
|
int zmq::tcp_socket_t::open (fd_t fd_, int sndbuf_, int rcvbuf_)
|
||||||
{
|
{
|
||||||
zmq_assert (s == retired_fd);
|
zmq_assert (s == retired_fd);
|
||||||
s = fd_;
|
s = fd_;
|
||||||
|
|
||||||
if (sndbuf_) {
|
if (sndbuf_) {
|
||||||
int sz = (int) sndbuf_;
|
|
||||||
int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF,
|
int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF,
|
||||||
(char*) &sz, sizeof (int));
|
(char*) &sndbuf_, sizeof (int));
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rcvbuf_) {
|
if (rcvbuf_) {
|
||||||
int sz = (int) rcvbuf_;
|
int sz = (int) rcvbuf_;
|
||||||
int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF,
|
int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF,
|
||||||
(char*) &sz, sizeof (int));
|
(char*) &rcvbuf_, sizeof (int));
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,20 +144,18 @@ zmq::tcp_socket_t::~tcp_socket_t ()
|
|||||||
close ();
|
close ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tcp_socket_t::open (fd_t fd_, uint64_t sndbuf_, uint64_t rcvbuf_)
|
int zmq::tcp_socket_t::open (fd_t fd_, int sndbuf_, int rcvbuf_)
|
||||||
{
|
{
|
||||||
assert (s == retired_fd);
|
assert (s == retired_fd);
|
||||||
s = fd_;
|
s = fd_;
|
||||||
|
|
||||||
if (sndbuf_) {
|
if (sndbuf_) {
|
||||||
int sz = (int) sndbuf_;
|
int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF, &sndbuf_, sizeof (int));
|
||||||
int rc = setsockopt (s, SOL_SOCKET, SO_SNDBUF, &sz, sizeof (int));
|
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rcvbuf_) {
|
if (rcvbuf_) {
|
||||||
int sz = (int) rcvbuf_;
|
int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF, &rcvbuf_, sizeof (int));
|
||||||
int rc = setsockopt (s, SOL_SOCKET, SO_RCVBUF, &sz, sizeof (int));
|
|
||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace zmq
|
|||||||
~tcp_socket_t ();
|
~tcp_socket_t ();
|
||||||
|
|
||||||
// Associates a socket with a native socket descriptor.
|
// Associates a socket with a native socket descriptor.
|
||||||
int open (fd_t fd_, uint64_t sndbuf_, uint64_t rcvbuf_);
|
int open (fd_t fd_, int sndbuf_, int rcvbuf_);
|
||||||
|
|
||||||
// Closes the underlying socket.
|
// Closes the underlying socket.
|
||||||
int close ();
|
int close ();
|
||||||
|
|||||||
Reference in New Issue
Block a user