Commit c3510af1 authored by Matt Stancliff's avatar Matt Stancliff Committed by antirez
Browse files

Fix potentially incorrect errno usage

errno may be reset by the previous call to redisLog, so capture
the original value for proper error reporting.
parent 771f8ad0
...@@ -1461,6 +1461,7 @@ void adjustOpenFilesLimit(void) { ...@@ -1461,6 +1461,7 @@ void adjustOpenFilesLimit(void) {
if (f < oldlimit) f = oldlimit; if (f < oldlimit) f = oldlimit;
if (f != maxfiles) { if (f != maxfiles) {
int old_maxclients = server.maxclients; int old_maxclients = server.maxclients;
int original_errno = errno;
server.maxclients = f-REDIS_MIN_RESERVED_FDS; server.maxclients = f-REDIS_MIN_RESERVED_FDS;
if (server.maxclients < 1) { if (server.maxclients < 1) {
redisLog(REDIS_WARNING,"Your current 'ulimit -n' " redisLog(REDIS_WARNING,"Your current 'ulimit -n' "
...@@ -1474,7 +1475,7 @@ void adjustOpenFilesLimit(void) { ...@@ -1474,7 +1475,7 @@ void adjustOpenFilesLimit(void) {
old_maxclients, maxfiles); old_maxclients, maxfiles);
redisLog(REDIS_WARNING,"Redis can't set maximum open files " redisLog(REDIS_WARNING,"Redis can't set maximum open files "
"to %llu because of OS error: %s.", "to %llu because of OS error: %s.",
maxfiles, strerror(errno)); maxfiles, strerror(original_errno));
redisLog(REDIS_WARNING,"Current maximum open files is %llu. " redisLog(REDIS_WARNING,"Current maximum open files is %llu. "
"maxclients has been reduced to %d to compensate for " "maxclients has been reduced to %d to compensate for "
"low ulimit. " "low ulimit. "
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment