summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/xs_getsockopt.txt9
-rw-r--r--doc/xs_setsockopt.txt6
-rw-r--r--include/xs.h2
-rw-r--r--src/decoder.cpp6
-rw-r--r--src/decoder.hpp4
-rw-r--r--src/options.cpp13
-rw-r--r--src/options.hpp2
-rw-r--r--src/upoll.cpp6
-rw-r--r--src/upoll.hpp2
-rw-r--r--src/xs.cpp2
-rw-r--r--src/xszmq.cpp2
11 files changed, 26 insertions, 28 deletions
diff --git a/doc/xs_getsockopt.txt b/doc/xs_getsockopt.txt
index e7ddb8e..5a09453 100644
--- a/doc/xs_getsockopt.txt
+++ b/doc/xs_getsockopt.txt
@@ -269,16 +269,15 @@ Applicable socket types:: all, only for connection-oriented transports
XS_MAXMSGSIZE: Maximum acceptable inbound message size
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The option shall retrieve limit for the inbound messages. If a peer sends
-a message larger than XS_MAXMSGSIZE it is disconnected. Value of -1 means
-'no limit'.
+a message larger than XS_MAXMSGSIZE it is disconnected.
[horizontal]
-Option value type:: int64_t
+Option value type:: uint64_t
Option value unit:: bytes
-Default value:: -1
+Default value:: 2^64-1
Applicable socket types:: all
diff --git a/doc/xs_setsockopt.txt b/doc/xs_setsockopt.txt
index 7cb91d2..6263a26 100644
--- a/doc/xs_setsockopt.txt
+++ b/doc/xs_setsockopt.txt
@@ -280,12 +280,12 @@ XS_MAXMSGSIZE: Maximum acceptable inbound message size
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Limits the size of the inbound message. If a peer sends a message larger than
-XS_MAXMSGSIZE it is disconnected. Value of -1 means 'no limit'.
+XS_MAXMSGSIZE it is disconnected.
[horizontal]
-Option value type:: int64_t
+Option value type:: uint64_t
Option value unit:: bytes
-Default value:: -1
+Default value:: 2^64-1
Applicable socket types:: all
diff --git a/include/xs.h b/include/xs.h
index f61a41a..5c781ea 100644
--- a/include/xs.h
+++ b/include/xs.h
@@ -239,7 +239,7 @@ typedef struct
short revents;
} xs_pollitem_t;
-XS_EXPORT int xs_poll (xs_pollitem_t *items, int nitems, long timeout);
+XS_EXPORT int xs_poll (xs_pollitem_t *items, int nitems, int timeout);
/******************************************************************************/
/* The following utility functions are exported for use from language */
diff --git a/src/decoder.cpp b/src/decoder.cpp
index a7f669a..23546f1 100644
--- a/src/decoder.cpp
+++ b/src/decoder.cpp
@@ -28,7 +28,7 @@
#include "wire.hpp"
#include "err.hpp"
-xs::decoder_t::decoder_t (size_t bufsize_, int64_t maxmsgsize_) :
+xs::decoder_t::decoder_t (size_t bufsize_, uint64_t maxmsgsize_) :
decoder_base_t <decoder_t> (bufsize_),
session (NULL),
maxmsgsize (maxmsgsize_)
@@ -70,7 +70,7 @@ bool xs::decoder_t::one_byte_size_ready ()
// close it before calling xs_msg_init_size, however, it's a 0-byte
// message and thus we can treat it as uninitialised...
int rc;
- if (maxmsgsize >= 0 && (int64_t) (*tmpbuf - 1) > maxmsgsize) {
+ if (maxmsgsize >= 0 && (uint64_t) (*tmpbuf - 1) > maxmsgsize) {
rc = -1;
errno = ENOMEM;
}
@@ -105,7 +105,7 @@ bool xs::decoder_t::eight_byte_size_ready ()
// close it before calling xs_msg_init_size, however, it's a 0-byte
// message and thus we can treat it as uninitialised...
int rc;
- if (maxmsgsize >= 0 && (int64_t) (size - 1) > maxmsgsize) {
+ if (maxmsgsize >= 0 && (uint64_t) (size - 1) > maxmsgsize) {
rc = -1;
errno = ENOMEM;
}
diff --git a/src/decoder.hpp b/src/decoder.hpp
index 9131861..c0ca85a 100644
--- a/src/decoder.hpp
+++ b/src/decoder.hpp
@@ -193,7 +193,7 @@ namespace xs
{
public:
- decoder_t (size_t bufsize_, int64_t maxmsgsize_);
+ decoder_t (size_t bufsize_, uint64_t maxmsgsize_);
~decoder_t ();
void set_session (xs::session_base_t *session_);
@@ -209,7 +209,7 @@ namespace xs
unsigned char tmpbuf [8];
msg_t in_progress;
- int64_t maxmsgsize;
+ uint64_t maxmsgsize;
decoder_t (const decoder_t&);
void operator = (const decoder_t&);
diff --git a/src/options.cpp b/src/options.cpp
index 50ef379..2b123c2 100644
--- a/src/options.cpp
+++ b/src/options.cpp
@@ -21,6 +21,7 @@
*/
#include <string.h>
+#include <limits>
#include "options.hpp"
#include "err.hpp"
@@ -40,7 +41,7 @@ xs::options_t::options_t () :
reconnect_ivl (100),
reconnect_ivl_max (0),
backlog (100),
- maxmsgsize (-1),
+ maxmsgsize (std::numeric_limits <uint64_t>::max ()),
rcvtimeo (-1),
sndtimeo (-1),
ipv4only (1),
@@ -169,11 +170,11 @@ int xs::options_t::setsockopt (int option_, const void *optval_,
return 0;
case XS_MAXMSGSIZE:
- if (optvallen_ != sizeof (int64_t)) {
+ if (optvallen_ != sizeof (uint64_t)) {
errno = EINVAL;
return -1;
}
- maxmsgsize = *((int64_t*) optval_);
+ maxmsgsize = *((uint64_t*) optval_);
return 0;
case XS_MULTICAST_HOPS:
@@ -343,12 +344,12 @@ int xs::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
return 0;
case XS_MAXMSGSIZE:
- if (*optvallen_ < sizeof (int64_t)) {
+ if (*optvallen_ < sizeof (uint64_t)) {
errno = EINVAL;
return -1;
}
- *((int64_t*) optval_) = maxmsgsize;
- *optvallen_ = sizeof (int64_t);
+ *((uint64_t*) optval_) = maxmsgsize;
+ *optvallen_ = sizeof (uint64_t);
return 0;
case XS_MULTICAST_HOPS:
diff --git a/src/options.hpp b/src/options.hpp
index 0bb3cf9..1ea61bd 100644
--- a/src/options.hpp
+++ b/src/options.hpp
@@ -78,7 +78,7 @@ namespace xs
int backlog;
// Maximal size of message to handle.
- int64_t maxmsgsize;
+ uint64_t maxmsgsize;
// The timeout for send/recv operations for this socket.
int rcvtimeo;
diff --git a/src/upoll.cpp b/src/upoll.cpp
index 9e66279..3295bba 100644
--- a/src/upoll.cpp
+++ b/src/upoll.cpp
@@ -56,12 +56,10 @@
#include <unistd.h>
#endif
-#include <limits.h>
-
-int xs::upoll (xs_pollitem_t *items_, int nitems_, long timeout_)
+int xs::upoll (xs_pollitem_t *items_, int nitems_, int timeout_)
{
#if defined XS_POLL_BASED_ON_POLL
- if (unlikely (nitems_ < 0 || timeout_ > INT_MAX)) {
+ if (unlikely (nitems_ < 0)) {
errno = EINVAL;
return -1;
}
diff --git a/src/upoll.hpp b/src/upoll.hpp
index 9e6b5be..d63df5e 100644
--- a/src/upoll.hpp
+++ b/src/upoll.hpp
@@ -26,7 +26,7 @@
namespace xs
{
// Underlying function for xs_poll.
- int upoll (xs_pollitem_t *items_, int nitems_, long timeout_);
+ int upoll (xs_pollitem_t *items_, int nitems_, int timeout_);
}
#endif
diff --git a/src/xs.cpp b/src/xs.cpp
index 36d40da..7f4cdd2 100644
--- a/src/xs.cpp
+++ b/src/xs.cpp
@@ -347,7 +347,7 @@ int xs_getmsgopt (xs_msg_t *msg_, int option_, void *optval_,
}
}
-int xs_poll (xs_pollitem_t *items_, int nitems_, long timeout_)
+int xs_poll (xs_pollitem_t *items_, int nitems_, int timeout_)
{
return xs::upoll (items_, nitems_, timeout_);
}
diff --git a/src/xszmq.cpp b/src/xszmq.cpp
index d1fb20c..bac6985 100644
--- a/src/xszmq.cpp
+++ b/src/xszmq.cpp
@@ -377,7 +377,7 @@ int zmq_recv (void *s, zmq_msg_t *msg, int flags)
int zmq_poll (zmq_pollitem_t *items, int nitems, long timeout)
{
- return xs_poll ((xs_pollitem_t*) items, nitems, timeout / 1000);
+ return xs_poll ((xs_pollitem_t*) items, nitems, (int) (timeout / 1000));
}
int zmq_device (int device, void *frontend, void *backend)