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 */
|
/* for IPv6 */
|
||||||
#vhost6 = "3ffe:80e8:546::2";
|
#vhost6 = "3ffe:80e8:546::2";
|
||||||
|
|
||||||
/* max_clients: This should be set to the maximum amount of clients
|
/* default max clients: the default maximum number of clients
|
||||||
* that the server should support. Note that you should leave some
|
* allowed to connect. This can be changed once ircd has started by
|
||||||
* file descriptors free for log files, server connections, ident
|
* issuing:
|
||||||
* lookups (if enabled), exceed_limit clients, etc.
|
* /quote set maxclients <limit>
|
||||||
*/
|
*/
|
||||||
max_clients = 1024;
|
default_max_clients = 1024;
|
||||||
};
|
};
|
||||||
|
|
||||||
admin {
|
admin {
|
||||||
|
|
|
@ -116,12 +116,12 @@ serverinfo {
|
||||||
*/
|
*/
|
||||||
#vhost6 = "3ffe:80e8:546::2";
|
#vhost6 = "3ffe:80e8:546::2";
|
||||||
|
|
||||||
/* max_clients: this should be set to the maximum amount of clients
|
/* default max clients: the default maximum number of clients
|
||||||
* that the server should support. Note that you should leave some
|
* allowed to connect. This can be changed once ircd has started by
|
||||||
* file descriptors free for log files, server connections, ident
|
* issuing:
|
||||||
* lookups (if enabled), exceed_limit clients, etc.
|
* /quote set maxclients <limit>
|
||||||
*/
|
*/
|
||||||
max_clients = 1024;
|
default_max_clients = 1024;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* admin {}: contains admin information about the server. (OLD A:) */
|
/* admin {}: contains admin information about the server. (OLD A:) */
|
||||||
|
|
|
@ -34,6 +34,9 @@
|
||||||
/*
|
/*
|
||||||
* First, set other fd limits based on values from user
|
* First, set other fd limits based on values from user
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#define MAXCONNECTIONS 65535 /* default max connections if getrlimit doesn't work */
|
||||||
/* class {} default values */
|
/* class {} default values */
|
||||||
#define DEFAULT_SENDQ 20000000 /* default max SendQ */
|
#define DEFAULT_SENDQ 20000000 /* default max SendQ */
|
||||||
#define PORTNUM 6667 /* default outgoing portnum */
|
#define PORTNUM 6667 /* default outgoing portnum */
|
||||||
|
|
|
@ -279,7 +279,7 @@ struct server_info
|
||||||
int specific_ipv6_vhost;
|
int specific_ipv6_vhost;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int max_clients;
|
int default_max_clients;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct admin_info
|
struct admin_info
|
||||||
|
|
|
@ -92,10 +92,10 @@ static struct InfoStruct info_table[] = {
|
||||||
"Farconnect notices available or operspy accountability limited"
|
"Farconnect notices available or operspy accountability limited"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"max_clients",
|
"max_connections",
|
||||||
OUTPUT_DECIMAL,
|
OUTPUT_DECIMAL,
|
||||||
&ServerInfo.max_clients,
|
&maxconnections,
|
||||||
"Maximum clients allowed (configured)",
|
"Max number connections"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"anti_nick_flood",
|
"anti_nick_flood",
|
||||||
|
|
|
@ -215,18 +215,18 @@ quote_max(struct Client *source_p, int newval)
|
||||||
{
|
{
|
||||||
if(newval > 0)
|
if(newval > 0)
|
||||||
{
|
{
|
||||||
if(newval > ServerInfo.max_clients)
|
if(newval > maxconnections - MAX_BUFFER)
|
||||||
{
|
{
|
||||||
sendto_one_notice(source_p,
|
sendto_one_notice(source_p,
|
||||||
":You cannot set MAXCLIENTS to > max_clients (%d)",
|
":You cannot set MAXCLIENTS to > %d",
|
||||||
ServerInfo.max_clients);
|
maxconnections - MAX_BUFFER);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newval < 32)
|
if(newval < 32)
|
||||||
{
|
{
|
||||||
sendto_one_notice(source_p, ":You cannot set MAXCLIENTS to < 32 (%d)",
|
sendto_one_notice(source_p, ":You cannot set MAXCLIENTS to < 32 (%d:%d)",
|
||||||
GlobalSetOptions.maxclients);
|
GlobalSetOptions.maxclients, rb_getmaxconnect());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
src/ircd.c
21
src/ircd.c
|
@ -76,7 +76,7 @@ extern int ServerRunning;
|
||||||
extern struct LocalUser meLocalUser;
|
extern struct LocalUser meLocalUser;
|
||||||
extern char **myargv;
|
extern char **myargv;
|
||||||
|
|
||||||
int maxconnections; /* XXX */
|
int maxconnections;
|
||||||
|
|
||||||
/* /quote set variables */
|
/* /quote set variables */
|
||||||
struct SetOptions GlobalSetOptions;
|
struct SetOptions GlobalSetOptions;
|
||||||
|
@ -158,16 +158,17 @@ init_sys(void)
|
||||||
|
|
||||||
if(!getrlimit(RLIMIT_NOFILE, &limit))
|
if(!getrlimit(RLIMIT_NOFILE, &limit))
|
||||||
{
|
{
|
||||||
limit.rlim_cur = limit.rlim_max; /* make soft limit the max */
|
maxconnections = limit.rlim_cur;
|
||||||
if(setrlimit(RLIMIT_NOFILE, &limit) == -1)
|
if(maxconnections <= MAX_BUFFER)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "error setting max fd's to %ld\n", (long) limit.rlim_cur);
|
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);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
#endif /* RLIMIT_FD_MAX */
|
||||||
maxconnections = limit.rlim_cur;
|
maxconnections = MAXCONNECTIONS;
|
||||||
#endif /* RLIMIT_NOFILE */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -279,7 +280,11 @@ initialize_global_set_options(void)
|
||||||
memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
|
memset(&GlobalSetOptions, 0, sizeof(GlobalSetOptions));
|
||||||
/* memset( &ConfigFileEntry, 0, sizeof(ConfigFileEntry)); */
|
/* 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.autoconn = 1;
|
||||||
|
|
||||||
GlobalSetOptions.spam_time = MIN_JOIN_LEAVE_TIME;
|
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 },
|
{ "vhost", CF_QSTRING, conf_set_serverinfo_vhost, 0, NULL },
|
||||||
{ "vhost6", CF_QSTRING, conf_set_serverinfo_vhost6, 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 }
|
{ "\0", 0, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,8 +36,6 @@
|
||||||
/* external var */
|
/* external var */
|
||||||
extern char **myargv;
|
extern char **myargv;
|
||||||
|
|
||||||
extern int maxconnections; /* XXX */
|
|
||||||
|
|
||||||
void
|
void
|
||||||
restart(const char *mesg)
|
restart(const char *mesg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -838,7 +838,7 @@ set_default_conf(void)
|
||||||
ConfigFileEntry.reject_duration = 120;
|
ConfigFileEntry.reject_duration = 120;
|
||||||
ConfigFileEntry.max_unknown_ip = 2;
|
ConfigFileEntry.max_unknown_ip = 2;
|
||||||
|
|
||||||
ServerInfo.max_clients = maxconnections - MAX_BUFFER;
|
ServerInfo.default_max_clients = MAXCONNECTIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef YES
|
#undef YES
|
||||||
|
|
Loading…
Reference in a new issue