diff options
author | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-08 16:58:37 +0000 |
---|---|---|
committer | w00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-09-08 16:58:37 +0000 |
commit | 484b718ccf1505360d62401dd09e3eca6b2568d8 (patch) | |
tree | 538e611bd6d7c3dea27077db9c154fdd3c23ab8a /src | |
parent | 0e07fc2e9e69270a110d8dc07007498b4d03b8b0 (diff) |
Move this to another (yet more appropriate) place, saves some syscalls in an unlikely condition.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10468 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/listensocket.cpp | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/listensocket.cpp b/src/listensocket.cpp index 07ff2886e..d6fe2bb1f 100644 --- a/src/listensocket.cpp +++ b/src/listensocket.cpp @@ -100,6 +100,24 @@ void ListenSocket::AcceptInternal() ServerInstance->stats->statsRefused++; return; } + /* + * XXX - + * this is done as a safety check to keep the file descriptors within range of fd_ref_table. + * its a pretty big but for the moment valid assumption: + * file descriptors are handed out starting at 0, and are recycled as theyre freed. + * therefore if there is ever an fd over 65535, 65536 clients must be connected to the + * irc server at once (or the irc server otherwise initiating this many connections, files etc) + * which for the time being is a physical impossibility (even the largest networks dont have more + * than about 10,000 users on ONE server!) + */ + if (incomingSockfd >= ServerInstance->SE->GetMaxFds()) + { + ServerInstance->Logs->Log("SOCKET", DEBUG, "Server is full"); + ServerInstance->SE->Shutdown(incomingSockfd, 2); + ServerInstance->SE->Close(incomingSockfd); + ServerInstance->stats->statsRefused++; + return; + } static char buf[MAXBUF]; static char target[MAXBUF]; @@ -127,25 +145,6 @@ void ListenSocket::AcceptInternal() ServerInstance->Logs->Log("SOCKET", DEBUG, "Can't get peername: %s", strerror(errno)); } - /* - * XXX - - * this is done as a safety check to keep the file descriptors within range of fd_ref_table. - * its a pretty big but for the moment valid assumption: - * file descriptors are handed out starting at 0, and are recycled as theyre freed. - * therefore if there is ever an fd over 65535, 65536 clients must be connected to the - * irc server at once (or the irc server otherwise initiating this many connections, files etc) - * which for the time being is a physical impossibility (even the largest networks dont have more - * than about 10,000 users on ONE server!) - */ - if (incomingSockfd >= ServerInstance->SE->GetMaxFds()) - { - ServerInstance->Logs->Log("SOCKET", DEBUG, "Server is full"); - ServerInstance->SE->Shutdown(incomingSockfd, 2); - ServerInstance->SE->Close(incomingSockfd); - ServerInstance->stats->statsRefused++; - return; - } - ServerInstance->SE->NonBlocking(incomingSockfd); ServerInstance->stats->statsAccept++; this->OnAcceptReady(target, incomingSockfd, buf); |