Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
ca3dd5e5
Commit
ca3dd5e5
authored
Dec 19, 2014
by
antirez
Browse files
Fix adjustOpenFilesLimit() logging to match real state.
Fixes issue #2225.
parent
6f0a7353
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/redis.c
View file @
ca3dd5e5
...
@@ -1477,33 +1477,33 @@ void adjustOpenFilesLimit(void) {
...
@@ -1477,33 +1477,33 @@ void adjustOpenFilesLimit(void) {
/* Set the max number of files if the current limit is not enough
/* Set the max number of files if the current limit is not enough
* for our needs. */
* for our needs. */
if
(
oldlimit
<
maxfiles
)
{
if
(
oldlimit
<
maxfiles
)
{
rlim_t
f
;
rlim_t
bestlimit
;
int
setrlimit_error
=
0
;
int
setrlimit_error
=
0
;
/* Try to set the file limit to match 'maxfiles' or at least
/* Try to set the file limit to match 'maxfiles' or at least
* to the higher value supported less than maxfiles. */
* to the higher value supported less than maxfiles. */
f
=
maxfiles
;
bestlimit
=
maxfiles
;
while
(
f
>
oldlimit
)
{
while
(
bestlimit
>
oldlimit
)
{
rlim_t
decr_step
=
16
;
rlim_t
decr_step
=
16
;
limit
.
rlim_cur
=
f
;
limit
.
rlim_cur
=
bestlimit
;
limit
.
rlim_max
=
f
;
limit
.
rlim_max
=
bestlimit
;
if
(
setrlimit
(
RLIMIT_NOFILE
,
&
limit
)
!=
-
1
)
break
;
if
(
setrlimit
(
RLIMIT_NOFILE
,
&
limit
)
!=
-
1
)
break
;
setrlimit_error
=
errno
;
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. */
* smaller limit decrementing by a few FDs per iteration. */
if
(
f
<
decr_step
)
break
;
if
(
bestlimit
<
decr_step
)
break
;
f
-=
decr_step
;
bestlimit
-=
decr_step
;
}
}
/* Assume that the limit we get initially is still valid if
/* Assume that the limit we get initially is still valid if
* our last try was even lower. */
* 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
;
int
old_maxclients
=
server
.
maxclients
;
server
.
maxclients
=
f
-
REDIS_MIN_RESERVED_FDS
;
server
.
maxclients
=
bestlimit
-
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' "
"of %llu is not enough for Redis to start. "
"of %llu is not enough for Redis to start. "
...
@@ -1524,7 +1524,7 @@ void adjustOpenFilesLimit(void) {
...
@@ -1524,7 +1524,7 @@ void adjustOpenFilesLimit(void) {
"maxclients has been reduced to %d to compensate for "
"maxclients has been reduced to %d to compensate for "
"low ulimit. "
"low ulimit. "
"If you need higher maxclients increase 'ulimit -n'."
,
"If you need higher maxclients increase 'ulimit -n'."
,
(
unsigned
long
long
)
old
limit
,
server
.
maxclients
);
(
unsigned
long
long
)
best
limit
,
server
.
maxclients
);
}
else
{
}
else
{
redisLog
(
REDIS_NOTICE
,
"Increased maximum number of open files "
redisLog
(
REDIS_NOTICE
,
"Increased maximum number of open files "
"to %llu (it was originally set to %llu)."
,
"to %llu (it was originally set to %llu)."
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment