From 832c612317589ce14bf5d69a1a032f3606561978 Mon Sep 17 00:00:00 2001 From: stskeeps Date: Thu, 17 May 2007 09:56:42 +0000 Subject: [PATCH] Index: Changes =================================================================== RCS file: /home/cmunk/ircsystems/cvsroot/unreal/Changes,v retrieving revision 1.1.1.1.2.1.2.1.2.2403 diff -u -r1.1.1.1.2.1.2.1.2.2403 Changes --- Changes 15 May 2007 00:38:07 -0000 1.1.1.1.2.1.2.1.2.2403 +++ Changes 17 May 2007 09:56:36 -0000 @@ -1702,3 +1702,8 @@ concept, so please tell me if some OS'es break bigtime. - #003075 - reported by aquanight regarding log block failing silently for non-creatable log files. Now fails with an error message. +- Now using #0003028, with more intelligent accept() handling. The IRCd + will now attempt to accept() up to LISTEN_SIZE (possibly saving CPU + through this under load, and speeding up connection). +- IRCd now also sets the &me fd as being non blocking (wasn't before, that + was odd..) --- Changes | 5 +++++ src/ircd.c | 2 ++ src/s_bsd.c | 36 ++++++++++++++++++++---------------- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/Changes b/Changes index c831c981f..681d33ee4 100644 --- a/Changes +++ b/Changes @@ -1702,3 +1702,8 @@ MOTDs concept, so please tell me if some OS'es break bigtime. - #003075 - reported by aquanight regarding log block failing silently for non-creatable log files. Now fails with an error message. +- Now using #0003028, with more intelligent accept() handling. The IRCd + will now attempt to accept() up to LISTEN_SIZE (possibly saving CPU + through this under load, and speeding up connection). +- IRCd now also sets the &me fd as being non blocking (wasn't before, that + was odd..) diff --git a/src/ircd.c b/src/ircd.c index e740993b6..85a72593d 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -1496,11 +1496,13 @@ int InitwIRCD(int argc, char *argv[]) #ifndef NEW_IO if (inetport(&me, conf_listen->ip, portnum)) exit(1); + set_non_blocking(me.fd, &me); #else /* ifndef NEW_IO */ #endif /* ifndef NEW_IO */ conf_listen->options |= LISTENER_BOUND; me.umodes = conf_listen->options; conf_listen->listener = &me; + run_configuration(); botmotd = (aMotd *) read_file(BPATH, NULL); rules = (aMotd *) read_file(RPATH, NULL); diff --git a/src/s_bsd.c b/src/s_bsd.c index d4eb3cabe..cf1d44766 100644 --- a/src/s_bsd.c +++ b/src/s_bsd.c @@ -1440,7 +1440,7 @@ int read_message(time_t delay, fdlist * listp) #else fd_set read_set, write_set, excpt_set; #endif - int j; + int j,k; time_t delay2 = delay, now; int res, length, fd, i; int auth = 0; @@ -1663,20 +1663,22 @@ int read_message(time_t delay, fdlist * listp) ** point, just assume that connections cannot ** be accepted until some old is closed first. */ - if ((fd = accept(cptr->fd, NULL, NULL)) < 0) + for (k = 0; k < LISTEN_SIZE; k++) { + if ((fd = accept(cptr->fd, NULL, NULL)) < 0) + { if ((ERRNO != P_EWOULDBLOCK) && (ERRNO != P_ECONNABORTED)) report_baderror ("Cannot accept connections %s:%s", cptr); break; - } - ircstp->is_ac++; - if (++OpenFiles >= MAXCLIENTS) - { - ircstp->is_ref++; - if (last_allinuse < TStime() - 15) + } + ircstp->is_ac++; + if (++OpenFiles >= MAXCLIENTS) + { + ircstp->is_ref++; + if (last_allinuse < TStime() - 15) { sendto_realops ("All connections in use. (%s)", @@ -1694,15 +1696,17 @@ int read_message(time_t delay, fdlist * listp) CLOSE_SOCK(fd); --OpenFiles; break; - } - /* - * Use of add_connection (which never fails :) meLazy - */ - (void)add_connection(cptr, fd); - nextping = TStime(); - if (!cptr->listener) + } + /* + * Use of add_connection (which never fails :) meLazy + */ + (void)add_connection(cptr, fd); + } + nextping = TStime(); + if (!cptr->listener) cptr->listener = &me; - } + + } #ifndef NO_FDLIST for (i = listp->entry[j = 1]; (j <= listp->last_entry); i = listp->entry[++j])