diff options
author | Martin Lucina <martin@lucina.net> | 2012-05-20 11:24:59 +0200 |
---|---|---|
committer | Martin Lucina <martin@lucina.net> | 2012-05-20 11:24:59 +0200 |
commit | e4a32d2c3227d8e2f3a2a3a3cb51bd021f57a8c2 (patch) | |
tree | 10978c613cca68ab3733e7d51c5c4963464f18df /src/options.cpp | |
parent | 0118255d0413fa469c0a7c569e05cc79bf5f5b7d (diff) | |
parent | 56619463ac26dc6c3e576d2fbf6b544eebeb5148 (diff) |
Merge tag 'upstream/2.2.0'
Upstream version 2.2.0
Diffstat (limited to 'src/options.cpp')
-rw-r--r-- | src/options.cpp | 49 |
1 files changed, 45 insertions, 4 deletions
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 <http://www.gnu.org/licenses/>. */ +#include <stdio.h> #include <string.h> #ifndef ZMQ_HAVE_WINDOWS #include <sys/stat.h> @@ -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; |