summaryrefslogtreecommitdiff
path: root/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'net.c')
-rw-r--r--net.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net.c b/net.c
index 2b591b9..0f36da2 100644
--- a/net.c
+++ b/net.c
@@ -70,7 +70,7 @@ ssize_t redisNetRead(redisContext *c, char *buf, size_t bufcap) {
__redisSetError(c, REDIS_ERR_TIMEOUT, "recv timeout");
return -1;
} else {
- __redisSetError(c, REDIS_ERR_IO, NULL);
+ __redisSetError(c, REDIS_ERR_IO, strerror(errno));
return -1;
}
} else if (nread == 0) {
@@ -82,15 +82,19 @@ ssize_t redisNetRead(redisContext *c, char *buf, size_t bufcap) {
}
ssize_t redisNetWrite(redisContext *c) {
- ssize_t nwritten = send(c->fd, c->obuf, sdslen(c->obuf), 0);
+ ssize_t nwritten;
+
+ nwritten = send(c->fd, c->obuf, sdslen(c->obuf), 0);
if (nwritten < 0) {
if ((errno == EWOULDBLOCK && !(c->flags & REDIS_BLOCK)) || (errno == EINTR)) {
- /* Try again later */
+ /* Try again */
+ return 0;
} else {
- __redisSetError(c, REDIS_ERR_IO, NULL);
+ __redisSetError(c, REDIS_ERR_IO, strerror(errno));
return -1;
}
}
+
return nwritten;
}