From d6d396790754dc03bfbde4d957c31e2170151bfd Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Tue, 13 Mar 2012 16:00:57 +0100 Subject: Type of XS_MAXMSGSIZE changed to uint64_t Signed-off-by: Martin Sustrik --- src/decoder.cpp | 6 +++--- src/decoder.hpp | 4 ++-- src/options.cpp | 13 +++++++------ src/options.hpp | 2 +- src/xszmq.cpp | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) (limited to 'src') 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 (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 +#include #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 ::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/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) -- cgit v1.2.3