Merge pull request #499 from jinq0123/fixbug/redisSetErrorFromErrno

Fix __redisSetErrorFromErrno() can not get error string.
This commit is contained in:
Jan-Erik Rediger 2017-01-23 17:03:14 +01:00 committed by GitHub
commit c9b72f97f8

3
net.c
View File

@ -65,12 +65,13 @@ static void redisContextCloseFd(redisContext *c) {
}
static void __redisSetErrorFromErrno(redisContext *c, int type, const char *prefix) {
int errorno = errno; /* snprintf() may change errno */
char buf[128] = { 0 };
size_t len = 0;
if (prefix != NULL)
len = snprintf(buf,sizeof(buf),"%s: ",prefix);
__redis_strerror_r(errno, (char *)(buf + len), sizeof(buf) - len);
__redis_strerror_r(errorno, (char *)(buf + len), sizeof(buf) - len);
__redisSetError(c,type,buf);
}