/* 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 {
*/
#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:) */
/*
* 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 */
int specific_ipv6_vhost;
#endif
- int max_clients;
+ int default_max_clients;
};
struct admin_info
&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",
{
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;
}
extern struct LocalUser meLocalUser;
extern char **myargv;
-int maxconnections; /* XXX */
+int maxconnections;
/* /quote set variables */\r
struct SetOptions GlobalSetOptions;
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
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;
{ "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 }
};
/* external var */
extern char **myargv;
-extern int maxconnections; /* XXX */
-
void
restart(const char *mesg)
{
ConfigFileEntry.reject_duration = 120;
ConfigFileEntry.max_unknown_ip = 2;
- ServerInfo.max_clients = maxconnections - MAX_BUFFER;
+ ServerInfo.default_max_clients = MAXCONNECTIONS;
}
#undef YES