From 338a8a0ee13388aceafa3d8b6d8add3b79e95986 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 20 May 2012 08:17:42 +0200 Subject: Expired survey returns ETIMEDOUT instead of EAGAIN Up to now, when survey in surveyor pattern expired, xs_recv() returned EAGAIN. That made it impossible to distinguish epired survey from expired receive timeout (XS_RCVTIMEO). This patch make errors different in both cases. Signed-off-by: Martin Sustrik --- src/surveyor.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/surveyor.cpp') diff --git a/src/surveyor.cpp b/src/surveyor.cpp index b72b91b..bd19b8a 100644 --- a/src/surveyor.cpp +++ b/src/surveyor.cpp @@ -92,8 +92,16 @@ int xs::surveyor_t::xrecv (msg_t *msg_, int flags_) // Get the first part of the response -- the survey ID. rc = xsurveyor_t::xrecv (msg_, flags_); - if (rc != 0) - return rc; + if (rc != 0) { + if (errno != EAGAIN) + return -1; + + // In case of AGAIN we should check whether the survey timeout expired. + // If so, we should return ETIMEDOUT so that user is able to + // distinguish survey timeout from RCVTIMEO-caused timeout. + errno = now_ms () >= timeout ? ETIMEDOUT : EAGAIN; + return -1; + } // Check whether this is response for the onging survey. If not, we can // drop the response. -- cgit v1.2.3