summaryrefslogtreecommitdiff
path: root/src/rio.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-10-22 15:58:13 +0200
committerantirez <antirez@gmail.com>2014-10-22 15:58:14 +0200
commitb50e3215d279d5eee6947bcba619fb1edb407f77 (patch)
treea7643aad3f32645079119f33d9eab0ac74008a79 /src/rio.c
parentd4f6a1711defdc0b63629c797b550abbcca2b96f (diff)
downloadredis-b50e3215d279d5eee6947bcba619fb1edb407f77.tar.gz
Translate rio fdset target EWOULDBLOCK error into ETIMEDOUT.
EWOULDBLOCK with the fdset rio target is returned when we try to write but the send timeout socket option triggered an error. Better to translate the error in something the user can actually recognize as a timeout.
Diffstat (limited to 'src/rio.c')
-rw-r--r--src/rio.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rio.c b/src/rio.c
index 2083486c2..738e56fd0 100644
--- a/src/rio.c
+++ b/src/rio.c
@@ -203,7 +203,14 @@ static size_t rioFdsetWrite(rio *r, const void *buf, size_t len) {
size_t nwritten = 0;
while(nwritten != count) {
retval = write(r->io.fdset.fds[j],p+nwritten,count-nwritten);
- if (retval <= 0) break;
+ if (retval <= 0) {
+ /* With blocking sockets, which is the sole user of this
+ * rio target, EWOULDBLOCK is returned only because of
+ * the SO_SNDTIMEO socket option, so we translate the error
+ * into one more recognizable by the user. */
+ if (retval == -1 && errno == EWOULDBLOCK) errno = ETIMEDOUT;
+ break;
+ }
nwritten += retval;
}