summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-29 16:33:26 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-29 16:33:26 +0000
commitdc12fcac8757b36b7da88d0a9ff25acc009d539c (patch)
treec8c728e8586da7152f33e482bf166e7e7789c8f8
parent024f972eb1ffc67bb32b2f083955199cbd6ecdde (diff)
Added extra checking to socketengine to refuse connections after we reach the max
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2697 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/socketengine.h1
-rw-r--r--src/socketengine.cpp8
2 files changed, 7 insertions, 2 deletions
diff --git a/include/socketengine.h b/include/socketengine.h
index ecb8fa96e..caa4dc45b 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -67,6 +67,7 @@ const char X_READBIT = 0x80;
class SocketEngine {
int EngineHandle; /* Handle to the socket engine if needed */
+ int CurrentSetSize; /* Current number of descriptors in the engine */
#ifdef USE_SELECT
std::map<int,int> fds; /* List of file descriptors being monitored */
fd_set wfdset, rfdset; /* Readable and writeable sets for select() */
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 3e0b3814d..69838ff59 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -2,7 +2,7 @@
* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
- * Inspire is copyright (C) 2002-2005 ChatSpike-Dev.
+ * Inspire is copyright (C) 2002-2006 ChatSpike-Dev.
* E-mail:
* <brain@chatspike.net>
* <Craig@chatspike.net>
@@ -19,7 +19,6 @@
#include "inspircd.h"
#ifdef USE_EPOLL
#include <sys/epoll.h>
-#define EP_DELAY 5
#endif
#ifdef USE_KQUEUE
#include <sys/types.h>
@@ -67,6 +66,11 @@ bool SocketEngine::AddFd(int fd, bool readable, char type)
{
if ((fd < 0) || (fd > 65535))
return false;
+ if (GetRemainingFds() <= 1)
+ {
+ log(DEFAULT,"ERROR: System out of file descriptors!");
+ return false;
+ }
#ifdef USE_SELECT
fds[fd] = fd;
#endif