]> git.saurik.com Git - redis.git/commitdiff
Two small fixes to maxclients handling.
authorantirez <antirez@gmail.com>
Wed, 18 Apr 2012 09:31:24 +0000 (11:31 +0200)
committerantirez <antirez@gmail.com>
Wed, 18 Apr 2012 09:31:24 +0000 (11:31 +0200)
1) Don't accept maxclients set to < 0
2) Allow maxclients < 1024, it is useful for testing.

src/config.c
src/redis.c

index 9899dfbcba2bb748484aa05fd5ae015c0da9217c..6f98e5e5a8dd7a1d6e23a8198f447ea800518746 100644 (file)
@@ -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) {
index 7da9c54595af9cd91fd2b8d0881687c6c42d77d6..2b1007b5cbd4bcfc8bac8e948c694616517ae938 100644 (file)
@@ -1153,7 +1153,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));