[svn] - remove ALL braindead 2.8 I/O artifacts: MASTER_MAX, HARD_FDLIMIT, HARD_FDLIMIT_, MAXCONNECTIONS, MAX_CLIENTS, etc.

they are ALL gone. all of this stuff is now determined at runtime via getrlimit(2).
- due to this, devpoll is broken. i'm not motivated to fix it at the moment.
This commit is contained in:
nenolod 2007-04-03 02:21:31 -07:00
parent f71e18eee5
commit 6fcb8629ae
17 changed files with 87 additions and 89 deletions

View file

@ -1,3 +1,12 @@
jilles 2007/04/02 22:03:08 UTC (20070402-3350)
Log:
Repair operspy who !#channel, broken by me in r3283.
Changes: Modified:
+2 -2 trunk/modules/m_who.c (File Modified)
jilles 2007/04/01 22:20:00 UTC (20070401-3344)
Log:
Update bug report and IRC channel information.

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: config.h 1701 2006-06-27 16:25:52Z jilles $
* $Id: config.h 3354 2007-04-03 09:21:31Z nenolod $
*/
#ifndef INCLUDED_config_h
@ -146,11 +146,6 @@
*/
#define MAX_BUFFER 60
/* HARD_FDLIMIT_
* The maximum amount of FDs to use. MAX_CLIENTS is set in ./configure.
*/
#define HARD_FDLIMIT_ MAX_CLIENTS + MAX_BUFFER + 20
#define CONFIG_RATBOX_LEVEL_2
#include "defaults.h"

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: config.h.dist 3275 2007-03-18 16:29:31Z jilles $
* $Id: config.h.dist 3354 2007-04-03 09:21:31Z nenolod $
*/
#ifndef INCLUDED_config_h
@ -159,11 +159,6 @@
*/
#define MAX_BUFFER 60
/* HARD_FDLIMIT_
* The maximum amount of FDs to use. MAX_CLIENTS is set in ./configure.
*/
#define HARD_FDLIMIT_ MAX_CLIENTS + MAX_BUFFER + 20
#define CONFIG_RATBOX_LEVEL_2
#include "defaults.h"

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: defaults.h 6 2005-09-10 01:02:21Z nenolod $
* $Id: defaults.h 3354 2007-04-03 09:21:31Z nenolod $
*/
#ifndef INCLUDED_defaults_h
@ -34,12 +34,6 @@
/*
* First, set other fd limits based on values from user
*/
#ifndef HARD_FDLIMIT_
error HARD_FDLIMIT_ undefined
#endif
#define HARD_FDLIMIT (HARD_FDLIMIT_ - 10)
#define MAXCONNECTIONS HARD_FDLIMIT
#define MASTER_MAX (HARD_FDLIMIT - MAX_BUFFER)
/* class {} default values */
#define DEFAULT_SENDQ 20000000 /* default max SendQ */
#define PORTNUM 6667 /* default outgoing portnum */

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: m_info.h 70 2005-09-10 07:03:09Z nenolod $
* $Id: m_info.h 3354 2007-04-03 09:21:31Z nenolod $
*/
#ifndef INCLUDED_m_info_h
@ -64,9 +64,6 @@ Info MyInformation[] = {
{"RESVPATH", "NONE", 0, "Path to resv file"},
#endif
{"HARD_FDLIMIT_", "", HARD_FDLIMIT_,
"Maximum Number of File Descriptors Available"},
#ifdef HPATH
{"HPATH", HPATH, 0, "Path to Operator Help Files"},
#else

View file

@ -1 +1 @@
#define SERNO "20070401-3344"
#define SERNO "20070402-3350"

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: commio.c 3247 2007-03-05 18:42:24Z nenolod $
* $Id: commio.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "libcharybdis.h"
@ -56,6 +56,7 @@ static void comm_connect_callback(int fd, int status);
static PF comm_connect_timeout;
static void comm_connect_dns_callback(void *vptr, struct DNSReply *reply);
static PF comm_connect_tryconnect;
static int comm_max_connections = 0;
inline fde_t *
comm_locate_fd(int fd)
@ -140,10 +141,11 @@ comm_close_all(void)
int fd;
#endif
/* XXX someone tell me why we care about 4 fd's ? */
/* XXX btw, fd 3 is used for profiler ! */
for (i = 4; i < MAXCONNECTIONS; ++i)
/*
* we start at 4 to avoid giving fds where malloc messages
* could be written --nenolod
*/
for (i = 4; i < comm_max_connections; ++i)
{
fde_t *F = comm_locate_fd(i);
@ -600,7 +602,7 @@ comm_socket(int family, int sock_type, int proto, const char *note)
{
int fd;
/* First, make sure we aren't going to run out of file descriptors */
if(number_fd >= MASTER_MAX)
if(number_fd >= comm_max_connections)
{
errno = ENFILE;
return -1;
@ -658,7 +660,7 @@ int
comm_accept(int fd, struct sockaddr *pn, socklen_t *addrlen)
{
int newfd;
if(number_fd >= MASTER_MAX)
if(number_fd >= comm_max_connections)
{
errno = ENFILE;
return -1;
@ -722,7 +724,7 @@ fdlist_update_biggest(int fd, int opening)
{
if(fd < highest_fd)
return;
s_assert(fd < MAXCONNECTIONS);
s_assert(fd < comm_max_connections);
if(fd > highest_fd)
{
@ -749,10 +751,16 @@ void
fdlist_init(void)
{
static int initialized = 0;
struct rlimit limit;
if(!initialized)
{
memset(&fd_table, '\0', sizeof(dlink_list) * FD_HASH_SIZE);
/* set up comm_max_connections. */
if(!getrlimit(RLIMIT_NOFILE, &limit))
comm_max_connections = limit.rlim_cur;
initialized = 1;
}
}
@ -870,4 +878,10 @@ comm_note(int fd, const char *format, ...)
F->desc[0] = '\0';
}
extern int
comm_get_maxconnections(void)
{
fdlist_init();
return comm_max_connections;
}

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: commio.h 3229 2007-03-05 17:23:07Z nenolod $
* $Id: commio.h 3354 2007-04-03 09:21:31Z nenolod $
*/
#ifndef INCLUDED_commio_h
@ -188,6 +188,8 @@ extern void mangle_mapped_sockaddr(struct sockaddr *in);
#define mangle_mapped_sockaddr(x)
#endif
extern int comm_get_maxconnections(void);
extern fde_t *comm_locate_fd(int fd);
#endif /* INCLUDED_commio_h */

View file

@ -22,7 +22,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: devpoll.c 3229 2007-03-05 17:23:07Z nenolod $
* $Id: devpoll.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "config.h"
@ -32,8 +32,7 @@
#include "libcharybdis.h"
#define POLL_LENGTH HARD_FDLIMIT
#define POLL_LENGTH 1024
static void devpoll_update_events(int, short, PF *);
static int dpfd;

View file

@ -22,7 +22,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: poll.c 3245 2007-03-05 18:41:14Z nenolod $
* $Id: poll.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "config.h"
@ -63,14 +63,15 @@ void
init_netio(void)
{
int fd;
int maxconn = comm_get_maxconnections();
pollfd_list.pollfds = calloc(sizeof(struct pollfd), MAXCONNECTIONS);
pollfd_list.pollfds = calloc(sizeof(struct pollfd), maxconn);
for (fd = 0; fd < MAXCONNECTIONS; fd++)
for (fd = 0; fd < maxconn; fd++)
pollfd_list.pollfds[fd].fd = -1;
pollfd_list.maxindex = 0;
pollfd_list.allocated = MAXCONNECTIONS;
pollfd_list.allocated = maxconn;
}
static inline void

View file

@ -22,16 +22,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: select.c 3229 2007-03-05 17:23:07Z nenolod $
* $Id: select.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "config.h"
#include "libcharybdis.h"
#if HARD_FDLIMIT_ >= FD_SETSIZE
#error HARD_FDLIMIT_ must be less than FD_SETSIZE(try using poll instead of select)
#endif
/*
* Note that this is only a single list - multiple lists is kinda pointless
* under select because the list size is a function of the highest FD :-)

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: ircd.c 3251 2007-03-05 18:58:38Z nenolod $
* $Id: ircd.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "stdinc.h"
@ -144,15 +144,6 @@ init_sys(void)
if(!getrlimit(RLIMIT_FD_MAX, &limit))
{
if(limit.rlim_max < MAXCONNECTIONS)
{
fprintf(stderr, "ircd's bootstrap fd table is too big\n");
fprintf(stderr, "Hard Limit: %ld bootstrap size: %d\n",
(long) limit.rlim_max, MAXCONNECTIONS);
fprintf(stderr, "Fix MAXCONNECTIONS\n");
exit(-1);
}
limit.rlim_cur = limit.rlim_max; /* make soft limit the max */
if(setrlimit(RLIMIT_FD_MAX, &limit) == -1)
{

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: listener.c 1675 2006-06-15 22:32:23Z jilles $
* $Id: listener.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "stdinc.h"
@ -194,7 +194,11 @@ inetport(listener_t *listener)
}
}
/*
* At one point, we enforced a strange arbitrary limit here.
* We no longer do this, and just check if the fd is valid or not.
* -nenolod
*/
if(fd == -1)
{
report_error("opening listener socket %s:%s",
@ -202,14 +206,7 @@ inetport(listener_t *listener)
get_listener_name(listener), errno);
return 0;
}
else if((HARD_FDLIMIT - 10) < fd)
{
report_error("no more connections left for listener %s:%s",
get_listener_name(listener),
get_listener_name(listener), errno);
comm_close(fd);
return 0;
}
/*
* XXX - we don't want to do all this crap for a listener
* set_sock_opts(listener);
@ -488,14 +485,13 @@ static void
accept_connection(int pfd, void *data)
{
static time_t last_oper_notice = 0;
struct irc_sockaddr_storage sai;
socklen_t addrlen = sizeof(sai);
int fd;
listener_t *listener = data;
struct ConfItem *aconf;
char buf[BUFSIZE];
struct ConfItem *aconf;
char buf[BUFSIZE];
s_assert(listener != NULL);
if(listener == NULL)
return;
@ -525,8 +521,9 @@ accept_connection(int pfd, void *data)
/*
* check for connection limit
* TBD: this is stupid... either we have a socket or we don't. -nenolod
*/
if((MAXCONNECTIONS - 10) < fd)
if((comm_get_maxconnections() - 10) < fd)
{
++ServerStats->is_ref;
/*
@ -554,19 +551,19 @@ accept_connection(int pfd, void *data)
{
ServerStats->is_ref++;
if(ConfigFileEntry.dline_with_reason)
{
if (ircsnprintf(buf, sizeof(buf), "ERROR :*** Banned: %s\r\n", aconf->passwd) >= (sizeof(buf)-1))
{
buf[sizeof(buf) - 3] = '\r';
buf[sizeof(buf) - 2] = '\n';
buf[sizeof(buf) - 1] = '\0';
}
}
else
ircsprintf(buf, "ERROR :You have been D-lined.\r\n");
if(ConfigFileEntry.dline_with_reason)
{
if (ircsnprintf(buf, sizeof(buf), "ERROR :*** Banned: %s\r\n", aconf->passwd) >= (sizeof(buf)-1))
{
buf[sizeof(buf) - 3] = '\r';
buf[sizeof(buf) - 2] = '\n';
buf[sizeof(buf) - 1] = '\0';
}
}
else
ircsprintf(buf, "ERROR :You have been D-lined.\r\n");
write(fd, buf, strlen(buf));
write(fd, buf, strlen(buf));
comm_close(fd);
/* Re-register a new IO request for the next accept .. */

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: restart.c 3249 2007-03-05 18:51:17Z nenolod $
* $Id: restart.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "stdinc.h"
@ -55,6 +55,7 @@ void
server_reboot(void)
{
int i;
int maxconn = comm_get_maxconnections();
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Restarting server...");
@ -69,7 +70,7 @@ server_reboot(void)
* bah, for now, the program ain't coming back to here, so forcibly
* close everything the "wrong" way for now, and just LEAVE...
*/
for (i = 0; i < MAXCONNECTIONS; ++i)
for (i = 0; i < maxconn; ++i)
close(i);
unlink(pidFileName);

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: s_auth.c 3161 2007-01-25 07:23:01Z nenolod $ */
* $Id: s_auth.c 3354 2007-04-03 09:21:31Z nenolod $ */
/*
* Changes:
@ -286,7 +286,11 @@ start_auth_query(struct AuthRequest *auth)
++ServerStats->is_abad;
return 0;
}
if((MAXCONNECTIONS - 10) < fd)
/*
* TBD: this is a pointless arbitrary limit .. we either have a socket or not. -nenolod
*/
if((comm_get_maxconnections() - 10) < fd)
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"Can't allocate fd for auth on %s",

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: s_conf.c 3271 2007-03-18 14:44:24Z jilles $
* $Id: s_conf.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "stdinc.h"
@ -852,7 +852,7 @@ set_default_conf(void)
ConfigFileEntry.reject_ban_time = 300;
ConfigFileEntry.reject_duration = 120;
ServerInfo.max_clients = MAXCONNECTIONS;
ServerInfo.max_clients = comm_get_maxconnections();
}
#undef YES

View file

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* $Id: s_serv.c 3233 2007-03-05 17:28:27Z nenolod $
* $Id: s_serv.c 3354 2007-04-03 09:21:31Z nenolod $
*/
#include "stdinc.h"
@ -1368,8 +1368,10 @@ fork_server(struct Client *server)
goto fork_error;
else if(ret == 0)
{
int maxconn = comm_get_maxconnections();
/* set our fds as non blocking and close everything else */
for (i = 0; i < HARD_FDLIMIT; i++)
for (i = 0; i < maxconn; i++)
{