From 386a46946babca7b9962a94837ef96bb40b448c7 Mon Sep 17 00:00:00 2001 From: Matt Stancliff Date: Mon, 24 Mar 2014 13:21:15 -0400 Subject: [PATCH] Fix potentially incorrect errno usage errno may be reset by the previous call to redisLog, so capture the original value for proper error reporting. --- src/redis.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/redis.c b/src/redis.c index 853ef5c8e..dc3b30fca 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1534,6 +1534,7 @@ void adjustOpenFilesLimit(void) { if (f < oldlimit) f = oldlimit; if (f != maxfiles) { int old_maxclients = server.maxclients; + int original_errno = errno; server.maxclients = f-REDIS_MIN_RESERVED_FDS; if (server.maxclients < 1) { redisLog(REDIS_WARNING,"Your current 'ulimit -n' " @@ -1547,7 +1548,7 @@ void adjustOpenFilesLimit(void) { old_maxclients, maxfiles); redisLog(REDIS_WARNING,"Redis can't set maximum open files " "to %llu because of OS error: %s.", - maxfiles, strerror(errno)); + maxfiles, strerror(original_errno)); redisLog(REDIS_WARNING,"Current maximum open files is %llu. " "maxclients has been reduced to %d to compensate for " "low ulimit. " -- GitLab