]> jfr.im git - irc/rqf/shadowircd.git/commitdiff
Much clear maxconnections stuff - ported from ratbox3.
authorValery Yatsko <redacted>
Sat, 5 Apr 2008 19:56:15 +0000 (23:56 +0400)
committerValery Yatsko <redacted>
Sat, 5 Apr 2008 19:56:15 +0000 (23:56 +0400)
doc/example.conf
doc/reference.conf
include/defaults.h
include/s_conf.h
modules/m_info.c
modules/m_set.c
src/ircd.c
src/newconf.c
src/restart.c
src/s_conf.c

index fbac4a088c93b190568285671cbb1b76b93362a3..3346ce7ba2d80f8a2558e6ce711a4043d83d9d6d 100755 (executable)
@@ -43,12 +43,12 @@ serverinfo {
        /* for IPv6 */
        #vhost6 = "3ffe:80e8:546::2";
 
-       /* max_clients: This should be set to the maximum amount of clients
-        * that the server should support. Note that you should leave some
-        * file descriptors free for log files, server connections, ident
-        * lookups (if enabled), exceed_limit clients, etc.
+       /* default max clients: the default maximum number of clients\r
+        * allowed to connect.  This can be changed once ircd has started by\r
+        * issuing:\r
+        *   /quote set maxclients <limit>\r
         */
-       max_clients = 1024;
+       default_max_clients = 1024;
 };
 
 admin {
index 3238f39a62511003328a00089010a860693f54db..e1a6e6fdd6e31fb9ab7afc6ae57fd11f0a407168 100755 (executable)
@@ -116,12 +116,12 @@ serverinfo {
         */
        #vhost6 = "3ffe:80e8:546::2";
 
-       /* max_clients: this should be set to the maximum amount of clients
-        * that the server should support. Note that you should leave some
-        * file descriptors free for log files, server connections, ident
-        * lookups (if enabled), exceed_limit clients, etc.
+       /* default max clients: the default maximum number of clients\r
+        * allowed to connect.  This can be changed once ircd has started by\r
+        * issuing:\r
+        *   /quote set maxclients <limit>\r
         */
-       max_clients = 1024;
+       default_max_clients = 1024;
 };
 
 /* admin {}: contains admin information about the server. (OLD A:) */
index 99d644719006468ec18e847270f00df414498beb..5edd8b83bbc0bec0a691638790a9145aba0b2319 100644 (file)
@@ -34,6 +34,9 @@
 /*
  * First, set other fd limits based on values from user
  */
+
+
+#define MAXCONNECTIONS 65535 /* default max connections if getrlimit doesn't work */
 /* class {} default values */
 #define DEFAULT_SENDQ 20000000 /* default max SendQ */
 #define PORTNUM 6667           /* default outgoing portnum */
index 2a7661d8e6d3af6d3f15e03c1e2469f44239b3f2..79a8766fb8cdd80ee51a4d7fe3ee95f7a7ca7f72 100644 (file)
@@ -279,7 +279,7 @@ struct server_info
        int specific_ipv6_vhost;
 #endif
 
-       int max_clients;
+       int default_max_clients;
 };
 
 struct admin_info
index 5bbad557cc685e480ae38e608c030ff58c16aadd..aed3469ddc42a04a52a1a0541402f88acd9a966a 100644 (file)
@@ -91,11 +91,11 @@ static struct InfoStruct info_table[] = {
                &opers_see_all_users,
                "Farconnect notices available or operspy accountability limited"
        },
-       {
-               "max_clients",
-               OUTPUT_DECIMAL,
-               &ServerInfo.max_clients,
-               "Maximum clients allowed (configured)",
+       {\r
+               "max_connections",\r
+               OUTPUT_DECIMAL,\r
+               &maxconnections,\r
+               "Max number connections"\r
        },
        {
                "anti_nick_flood",
index 0224a369349d3373e0d8a10aac2d799b74d0c380..3f336c1edebe3af2c5f73e257a26fde265a13a5f 100644 (file)
@@ -215,18 +215,18 @@ quote_max(struct Client *source_p, int newval)
 {
        if(newval > 0)
        {
-               if(newval > ServerInfo.max_clients)
-               {
-                       sendto_one_notice(source_p,
-                                  ":You cannot set MAXCLIENTS to > max_clients (%d)",
-                                  ServerInfo.max_clients);
-                       return;
+               if(newval > maxconnections - MAX_BUFFER)\r
+               {\r
+                       sendto_one_notice(source_p,\r
+                                         ":You cannot set MAXCLIENTS to > %d",\r
+                                         maxconnections - MAX_BUFFER);\r
+                       return;\r
                }
 
                if(newval < 32)
                {
-                       sendto_one_notice(source_p, ":You cannot set MAXCLIENTS to < 32 (%d)",
-                                  GlobalSetOptions.maxclients);
+                       sendto_one_notice(source_p, ":You cannot set MAXCLIENTS to < 32 (%d:%d)",
+                                  GlobalSetOptions.maxclients, rb_getmaxconnect());
                        return;
                }
 
index 9708dc51e700b7d06c25a2bf859be452710ee573..5e108e0fd864ee202ec77065771de736ed777eb9 100644 (file)
@@ -76,7 +76,7 @@ extern int ServerRunning;
 extern struct LocalUser meLocalUser;
 extern char **myargv;
 
-int maxconnections; /* XXX */
+int maxconnections;
 
 /* /quote set variables */\r
 struct SetOptions GlobalSetOptions;
@@ -153,21 +153,22 @@ ircd_die_cb(const char *str)
 static void
 init_sys(void)
 {
-#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
-       struct rlimit limit;
-
-       if(!getrlimit(RLIMIT_NOFILE, &limit))
-       {
-               limit.rlim_cur = limit.rlim_max;        /* make soft limit the max */
-               if(setrlimit(RLIMIT_NOFILE, &limit) == -1)
-               {
-                       fprintf(stderr, "error setting max fd's to %ld\n", (long) limit.rlim_cur);
-                       exit(EXIT_FAILURE);
-               }
-       }
-
-       maxconnections = limit.rlim_cur;
-#endif /* RLIMIT_NOFILE */
+#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)\r
+       struct rlimit limit;\r
+\r
+       if(!getrlimit(RLIMIT_NOFILE, &limit))\r
+       {\r
+               maxconnections = limit.rlim_cur;\r
+               if(maxconnections <= MAX_BUFFER)\r
+               {\r
+                       fprintf(stderr, "ERROR: Shell FD limits are too low.\n");\r
+                       fprintf(stderr, "ERROR: ircd-ratbox reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);\r
+                       exit(EXIT_FAILURE);\r
+               }\r
+               return;\r
+       }\r
+#endif /* RLIMIT_FD_MAX */\r
+       maxconnections = MAXCONNECTIONS;
 }
 
 static int
@@ -279,7 +280,11 @@ initialize_global_set_options(void)
        memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
        /* memset( &ConfigFileEntry, 0, sizeof(ConfigFileEntry)); */
 
-       GlobalSetOptions.maxclients = ServerInfo.max_clients;
+       GlobalSetOptions.maxclients = ServerInfo.default_max_clients;\r
+\r
+       if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER))\r
+               GlobalSetOptions.maxclients = maxconnections - MAX_BUFFER;
+
        GlobalSetOptions.autoconn = 1;
 
        GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
index ce3fe84487ce615c41854aec1bf9db6cdeac73ab..e2032dadd0f0d5c3fc2a9c4c34808c4377a4ceaa 100644 (file)
@@ -1893,7 +1893,7 @@ static struct ConfEntry conf_serverinfo_table[] =
        { "vhost",              CF_QSTRING, conf_set_serverinfo_vhost,  0, NULL },
        { "vhost6",             CF_QSTRING, conf_set_serverinfo_vhost6, 0, NULL },
 
-       { "max_clients",        CF_INT,     NULL, 0, &ServerInfo.max_clients    },
+       { "default_max_clients",CF_INT,     NULL, 0, &ServerInfo.default_max_clients },
 
        { "\0", 0, NULL, 0, NULL }
 };
index 7dc5cf0e0c0a4d78bc36ee37c8345dffb8c018cb..ada978cf12e280112c81dbf16d8a4c40a69aa940 100644 (file)
@@ -36,8 +36,6 @@
 /* external var */
 extern char **myargv;
 
-extern int maxconnections; /* XXX */
-
 void
 restart(const char *mesg)
 {
index c0033d192a73ad5d8fdd9e7a76e72dc1ef27a2f7..db2eba749b5d84cec600adf250c00952d8308de3 100644 (file)
@@ -838,7 +838,7 @@ set_default_conf(void)
        ConfigFileEntry.reject_duration = 120;
        ConfigFileEntry.max_unknown_ip = 2;
 
-       ServerInfo.max_clients = maxconnections - MAX_BUFFER;
+       ServerInfo.default_max_clients = MAXCONNECTIONS;
 }
 
 #undef YES