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 | 56619463ac26dc6c3e576d2fbf6b544eebeb5148 (patch) | |
tree | f23e0eed3e7d347e71e5a6b4f983692bdec2078d /src/options.cpp | |
parent | 4016b657973bba87caf75168ba70aaa85d556487 (diff) |
Imported Upstream version 2.2.0upstream
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; |