mirror of
https://github.com/fluencelabs/redis
synced 2025-05-20 22:21:20 +00:00
When the user-provided 'maxclients' value is too big for the max number of files we can open, at least try to search the max the OS is allowing (in steps of 256 filedes).
This commit is contained in:
parent
31e2156c4b
commit
fbce475270
16
src/redis.c
16
src/redis.c
@ -1124,10 +1124,18 @@ void adjustOpenFilesLimit(void) {
|
||||
/* Set the max number of files if the current limit is not enough
|
||||
* for our needs. */
|
||||
if (oldlimit < maxfiles) {
|
||||
limit.rlim_cur = maxfiles;
|
||||
limit.rlim_max = maxfiles;
|
||||
if (setrlimit(RLIMIT_NOFILE,&limit) == -1) {
|
||||
server.maxclients = oldlimit-32;
|
||||
rlim_t f;
|
||||
|
||||
f = maxfiles;
|
||||
while(f > oldlimit) {
|
||||
limit.rlim_cur = f;
|
||||
limit.rlim_max = f;
|
||||
if (setrlimit(RLIMIT_NOFILE,&limit) != -1) break;
|
||||
f -= 128;
|
||||
}
|
||||
if (f < oldlimit) f = oldlimit;
|
||||
if (f != maxfiles) {
|
||||
server.maxclients = f-32;
|
||||
redisLog(REDIS_WARNING,"Unable to set the max number of files limit to %d (%s), setting the max clients configuration to %d.",
|
||||
(int) maxfiles, strerror(errno), (int) server.maxclients);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user