diff options
author | Martin Sustrik <sustrik@250bpm.com> | 2012-05-20 08:17:42 +0200 |
---|---|---|
committer | Martin Sustrik <sustrik@250bpm.com> | 2012-05-21 12:17:59 +0200 |
commit | 338a8a0ee13388aceafa3d8b6d8add3b79e95986 (patch) | |
tree | 6bb8fb957c3247e43c536bdd678a61bf59a12a02 /src | |
parent | c4881d317e3ec5b02d1e354fb54a56dc0618b717 (diff) |
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 <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/err.cpp | 2 | ||||
-rw-r--r-- | src/surveyor.cpp | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/err.cpp b/src/err.cpp index e330ed2..a771030 100644 --- a/src/err.cpp +++ b/src/err.cpp @@ -157,7 +157,7 @@ const char *xs::wsa_error_no (int no_) (no_ == WSAETOOMANYREFS) ? "Too many references can't splice" : (no_ == WSAETIMEDOUT) ? - "Connection timed out" : + "Operation timed out" : (no_ == WSAECONNREFUSED) ? "Connection refused" : (no_ == WSAELOOP) ? 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. |