From 727d6dd52a3e778403d2ef66a516498ff25f3c02 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 18 Apr 2012 11:31:24 +0200 Subject: [PATCH] Two small fixes to maxclients handling. 1) Don't accept maxclients set to < 0 2) Allow maxclients < 1024, it is useful for testing. --- src/config.c | 3 +++ src/redis.c | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/config.c b/src/config.c index 4d35521d..c2ea5b76 100644 --- a/src/config.c +++ b/src/config.c @@ -155,6 +155,9 @@ void loadServerConfigFromString(char *config) { loadServerConfig(argv[1],NULL); } else if (!strcasecmp(argv[0],"maxclients") && argc == 2) { server.maxclients = atoi(argv[1]); + if (server.maxclients < 1) { + err = "Invalid max clients limit"; goto loaderr; + } } else if (!strcasecmp(argv[0],"maxmemory") && argc == 2) { server.maxmemory = memtoll(argv[1],NULL); } else if (!strcasecmp(argv[0],"maxmemory-policy") && argc == 2) { diff --git a/src/redis.c b/src/redis.c index 86cf0d95..46ae3ffa 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1135,7 +1135,6 @@ void adjustOpenFilesLimit(void) { rlim_t maxfiles = server.maxclients+32; struct rlimit limit; - if (maxfiles < 1024) maxfiles = 1024; if (getrlimit(RLIMIT_NOFILE,&limit) == -1) { redisLog(REDIS_WARNING,"Unable to obtain the current NOFILE limit (%s), assuming 1024 and setting the max clients configuration accordingly.", strerror(errno)); -- GitLab