Much clear maxconnections stuff - ported from ratbox3.
This commit is contained in:
parent
2af8c7ff8b
commit
101db4c443
10 changed files with 51 additions and 45 deletions
|
@ -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
|
||||
* allowed to connect. This can be changed once ircd has started by
|
||||
* issuing:
|
||||
* /quote set maxclients <limit>
|
||||
*/
|
||||
max_clients = 1024;
|
||||
default_max_clients = 1024;
|
||||
};
|
||||
|
||||
admin {
|
||||
|
|
|
@ -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
|
||||
* allowed to connect. This can be changed once ircd has started by
|
||||
* issuing:
|
||||
* /quote set maxclients <limit>
|
||||
*/
|
||||
max_clients = 1024;
|
||||
default_max_clients = 1024;
|
||||
};
|
||||
|
||||
/* admin {}: contains admin information about the server. (OLD A:) */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -279,7 +279,7 @@ struct server_info
|
|||
int specific_ipv6_vhost;
|
||||
#endif
|
||||
|
||||
int max_clients;
|
||||
int default_max_clients;
|
||||
};
|
||||
|
||||
struct admin_info
|
||||
|
|
|
@ -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)",
|
||||
{
|
||||
"max_connections",
|
||||
OUTPUT_DECIMAL,
|
||||
&maxconnections,
|
||||
"Max number connections"
|
||||
},
|
||||
{
|
||||
"anti_nick_flood",
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
sendto_one_notice(source_p,
|
||||
":You cannot set MAXCLIENTS to > %d",
|
||||
maxconnections - MAX_BUFFER);
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
39
src/ircd.c
39
src/ircd.c
|
@ -76,7 +76,7 @@ extern int ServerRunning;
|
|||
extern struct LocalUser meLocalUser;
|
||||
extern char **myargv;
|
||||
|
||||
int maxconnections; /* XXX */
|
||||
int maxconnections;
|
||||
|
||||
/* /quote set variables */
|
||||
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)
|
||||
struct rlimit limit;
|
||||
|
||||
if(!getrlimit(RLIMIT_NOFILE, &limit))
|
||||
{
|
||||
maxconnections = limit.rlim_cur;
|
||||
if(maxconnections <= MAX_BUFFER)
|
||||
{
|
||||
fprintf(stderr, "ERROR: Shell FD limits are too low.\n");
|
||||
fprintf(stderr, "ERROR: ircd-ratbox reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif /* RLIMIT_FD_MAX */
|
||||
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;
|
||||
|
||||
if(GlobalSetOptions.maxclients > (maxconnections - MAX_BUFFER))
|
||||
GlobalSetOptions.maxclients = maxconnections - MAX_BUFFER;
|
||||
|
||||
GlobalSetOptions.autoconn = 1;
|
||||
|
||||
GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
|
||||
|
|
|
@ -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 }
|
||||
};
|
||||
|
|
|
@ -36,8 +36,6 @@
|
|||
/* external var */
|
||||
extern char **myargv;
|
||||
|
||||
extern int maxconnections; /* XXX */
|
||||
|
||||
void
|
||||
restart(const char *mesg)
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue