diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder.cpp | 6 | ||||
-rw-r--r-- | src/decoder.hpp | 4 | ||||
-rw-r--r-- | src/options.cpp | 13 | ||||
-rw-r--r-- | src/options.hpp | 2 | ||||
-rw-r--r-- | src/upoll.cpp | 6 | ||||
-rw-r--r-- | src/upoll.hpp | 2 | ||||
-rw-r--r-- | src/xs.cpp | 2 | ||||
-rw-r--r-- | src/xszmq.cpp | 2 |
8 files changed, 18 insertions, 19 deletions
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 @@ -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) |