Commit a5f83412 authored by antirez's avatar antirez
Browse files

Two small fixes to maxclients handling.

1) Don't accept maxclients set to < 0
2) Allow maxclients < 1024, it is useful for testing.
parent 6a3f0ac6
...@@ -155,6 +155,9 @@ void loadServerConfigFromString(char *config) { ...@@ -155,6 +155,9 @@ void loadServerConfigFromString(char *config) {
loadServerConfig(argv[1],NULL); loadServerConfig(argv[1],NULL);
} else if (!strcasecmp(argv[0],"maxclients") && argc == 2) { } else if (!strcasecmp(argv[0],"maxclients") && argc == 2) {
server.maxclients = atoi(argv[1]); server.maxclients = atoi(argv[1]);
if (server.maxclients < 1) {
err = "Invalid max clients limit"; goto loaderr;
}
} else if (!strcasecmp(argv[0],"maxmemory") && argc == 2) { } else if (!strcasecmp(argv[0],"maxmemory") && argc == 2) {
server.maxmemory = memtoll(argv[1],NULL); server.maxmemory = memtoll(argv[1],NULL);
} else if (!strcasecmp(argv[0],"maxmemory-policy") && argc == 2) { } else if (!strcasecmp(argv[0],"maxmemory-policy") && argc == 2) {
......
...@@ -1153,7 +1153,6 @@ void adjustOpenFilesLimit(void) { ...@@ -1153,7 +1153,6 @@ void adjustOpenFilesLimit(void) {
rlim_t maxfiles = server.maxclients+32; rlim_t maxfiles = server.maxclients+32;
struct rlimit limit; struct rlimit limit;
if (maxfiles < 1024) maxfiles = 1024;
if (getrlimit(RLIMIT_NOFILE,&limit) == -1) { 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.", redisLog(REDIS_WARNING,"Unable to obtain the current NOFILE limit (%s), assuming 1024 and setting the max clients configuration accordingly.",
strerror(errno)); strerror(errno));
......
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