summaryrefslogtreecommitdiff
path: root/src/redis.c
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-12-19 10:04:15 +0100
committerantirez <antirez@gmail.com>2014-12-19 10:04:15 +0100
commite3436dd9b886da95b62c347b68be5366877f7b91 (patch)
treeab05e202ebe82c2faf58242fcbbb96af6a4463b6 /src/redis.c
parentefbf5a125ec4647553bea1f91705f35e4c4e560c (diff)
downloadredis-e3436dd9b886da95b62c347b68be5366877f7b91.tar.gz
Fix adjustOpenFilesLimit() logging to match real state.
Fixes issue #2225.
Diffstat (limited to 'src/redis.c')
-rw-r--r--src/redis.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/redis.c b/src/redis.c
index 35429f934..e38f9247a 100644
--- a/src/redis.c
+++ b/src/redis.c
@@ -1566,33 +1566,33 @@ void adjustOpenFilesLimit(void) {
/* Set the max number of files if the current limit is not enough
* for our needs. */
if (oldlimit < maxfiles) {
- rlim_t f;
+ rlim_t bestlimit;
int setrlimit_error = 0;
/* Try to set the file limit to match 'maxfiles' or at least
* to the higher value supported less than maxfiles. */
- f = maxfiles;
- while(f > oldlimit) {
+ bestlimit = maxfiles;
+ while(bestlimit > oldlimit) {
rlim_t decr_step = 16;
- limit.rlim_cur = f;
- limit.rlim_max = f;
+ limit.rlim_cur = bestlimit;
+ limit.rlim_max = bestlimit;
if (setrlimit(RLIMIT_NOFILE,&limit) != -1) break;
setrlimit_error = errno;
- /* We failed to set file limit to 'f'. Try with a
+ /* We failed to set file limit to 'bestlimit'. Try with a
* smaller limit decrementing by a few FDs per iteration. */
- if (f < decr_step) break;
- f -= decr_step;
+ if (bestlimit < decr_step) break;
+ bestlimit -= decr_step;
}
/* Assume that the limit we get initially is still valid if
* our last try was even lower. */
- if (f < oldlimit) f = oldlimit;
+ if (bestlimit < oldlimit) bestlimit = oldlimit;
- if (f != maxfiles) {
+ if (bestlimit < maxfiles) {
int old_maxclients = server.maxclients;
- server.maxclients = f-REDIS_MIN_RESERVED_FDS;
+ server.maxclients = bestlimit-REDIS_MIN_RESERVED_FDS;
if (server.maxclients < 1) {
redisLog(REDIS_WARNING,"Your current 'ulimit -n' "
"of %llu is not enough for Redis to start. "
@@ -1613,7 +1613,7 @@ void adjustOpenFilesLimit(void) {
"maxclients has been reduced to %d to compensate for "
"low ulimit. "
"If you need higher maxclients increase 'ulimit -n'.",
- (unsigned long long) oldlimit, server.maxclients);
+ (unsigned long long) bestlimit, server.maxclients);
} else {
redisLog(REDIS_NOTICE,"Increased maximum number of open files "
"to %llu (it was originally set to %llu).",