From dc4ed5a7b59f1d5b4e4f7fb4b6e29ecaf5e6cc5c Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Mon, 16 Apr 2012 07:47:00 +0200 Subject: 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 --- src/options.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/options.cpp') 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; -- cgit v1.2.3