diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-04-16 07:47:00 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-04-17 07:34:37 +0200 |
commit | dc4ed5a7b59f1d5b4e4f7fb4b6e29ecaf5e6cc5c (patch) | |
tree | 29987586f7012a31c187de491edc99aea174473b /src/options.cpp | |
parent | 443d06f894751062da6d69238ce09f6fbfc27577 (diff) |
XS_SURVEY_TIMEOUT socket option added.
It can be used to timeout the survey. Value is in milliseconds
and -1 means infinite (default).
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src/options.cpp')
-rw-r--r-- | src/options.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/options.cpp b/src/options.cpp index 2a72add..f7bbdc4 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -50,6 +50,7 @@ xs::options_t::options_t () : keepalive (0), protocol (0), filter (XS_FILTER_PREFIX), + survey_timeout (-1), delay_on_close (true), delay_on_disconnect (true), send_identity (false), @@ -258,6 +259,18 @@ int xs::options_t::setsockopt (int option_, const void *optval_, filter = *((int*) optval_); return 0; + case XS_SURVEY_TIMEOUT: + if (type != XS_SURVEYOR) { + errno = ENOTSUP; + return -1; + } + if (optvallen_ != sizeof (int)) { + errno = EINVAL; + return -1; + } + survey_timeout = *((int*) optval_); + return 0; + } errno = EINVAL; @@ -457,6 +470,19 @@ int xs::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = sizeof (int); return 0; + case XS_SURVEY_TIMEOUT: + if (type != XS_SURVEYOR) { + errno = ENOTSUP; + return -1; + } + if (*optvallen_ < sizeof (int)) { + errno = EINVAL; + return -1; + } + *((int*) optval_) = survey_timeout; + *optvallen_ = sizeof (int); + return 0; + } errno = EINVAL; |