From 56619463ac26dc6c3e576d2fbf6b544eebeb5148 Mon Sep 17 00:00:00 2001 From: Martin Lucina Date: Sun, 20 May 2012 11:24:59 +0200 Subject: Imported Upstream version 2.2.0 --- src/options.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) (limited to 'src/options.cpp') diff --git a/src/options.cpp b/src/options.cpp index 952907b..75821da 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ +#include #include #ifndef ZMQ_HAVE_WINDOWS #include @@ -44,7 +45,9 @@ zmq::options_t::options_t () : backlog (100), requires_in (false), requires_out (false), - immediate_connect (true) + immediate_connect (true), + rcvtimeo (-1), + sndtimeo (-1) { } @@ -68,7 +71,11 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, } // Check that SWAP directory (.) is writable struct stat stat_buf; - if (stat (".", &stat_buf) || ((stat_buf.st_mode & S_IWRITE) == 0)) { +#if (ZMQ_HAVE_ANDROID || ZMQ_HAVE_LINUX) + if (stat (".", &stat_buf) || ((stat_buf.st_mode & S_IWUSR) == 0)) { +#else + if (stat (".", &stat_buf) || ((stat_buf.st_mode & S_IWRITE) == 0)) { +#endif errno = EACCES; return -1; } @@ -103,7 +110,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, } rate = (uint32_t) *((int64_t*) optval_); return 0; - + case ZMQ_RECOVERY_IVL: if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) { errno = EINVAL; @@ -191,6 +198,22 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, backlog = *((int*) optval_); return 0; + case ZMQ_RCVTIMEO: + if (optvallen_ != sizeof (int)) { + errno = EINVAL; + return -1; + } + rcvtimeo = *((int*) optval_); + return 0; + + case ZMQ_SNDTIMEO: + if (optvallen_ != sizeof (int)) { + errno = EINVAL; + return -1; + } + sndtimeo = *((int*) optval_); + return 0; + } errno = EINVAL; @@ -246,7 +269,7 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *((int64_t*) optval_) = rate; *optvallen_ = sizeof (int64_t); return 0; - + case ZMQ_RECOVERY_IVL: if (*optvallen_ < sizeof (int64_t)) { errno = EINVAL; @@ -337,6 +360,24 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = sizeof (int); return 0; + case ZMQ_RCVTIMEO: + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = rcvtimeo; + *optvallen_ = sizeof (int); + return 0; + + case ZMQ_SNDTIMEO: + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = sndtimeo; + *optvallen_ = sizeof (int); + return 0; + } errno = EINVAL; -- cgit v1.2.3