Much clear maxconnections stuff - ported from ratbox3.

This commit is contained in:
Valery Yatsko 2008-04-05 23:56:15 +04:00
parent 7bab07d4d3
commit 3fe908250a
10 changed files with 51 additions and 45 deletions

View File

@ -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 {

View File

@ -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:) */

View File

@ -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 */

View File

@ -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

View File

@ -91,11 +91,11 @@ static struct InfoStruct info_table[] = {
&opers_see_all_users, &opers_see_all_users,
"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",

View File

@ -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;
} }

View File

@ -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;
@ -153,21 +153,22 @@ ircd_die_cb(const char *str)
static void static void
init_sys(void) init_sys(void)
{ {
#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H) #if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
struct rlimit limit; struct rlimit limit;
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");
exit(EXIT_FAILURE); fprintf(stderr, "ERROR: ircd-ratbox reserves %d FDs, shell limits must be above this\n", MAX_BUFFER);
} exit(EXIT_FAILURE);
} }
return;
maxconnections = limit.rlim_cur; }
#endif /* RLIMIT_NOFILE */ #endif /* RLIMIT_FD_MAX */
maxconnections = MAXCONNECTIONS;
} }
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;

View File

@ -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 }
}; };

View File

@ -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)
{ {

View File

@ -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