summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-29 14:03:14 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-29 14:03:14 +0000
commit024f972eb1ffc67bb32b2f083955199cbd6ecdde (patch)
treee5d0fe90854d116e93d1ce45849e0e8586d02f89 /src
parentb0cb12952a378d4d3717d3a5556325a15be1de0a (diff)
Added counters for MAX_DESCRIPTORS etc which allows the socket engine to refuse new fd's once you hit the OS limit
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2696 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp6
-rw-r--r--src/socketengine.cpp31
2 files changed, 31 insertions, 6 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 6f1889bbf..fbcfc12d1 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -474,13 +474,9 @@ int InspIRCd::Run()
* descriptors in its list... dns, modules, users,
* servers... so its nice and easy, just one call.
*/
- numberactive = SE->Wait(activefds);
-
- if (!numberactive)
+ if (!(numberactive = SE->Wait(activefds)))
continue;
- log(DEBUG,"%d active fds this time around",numberactive);
-
/**
* Now process each of the fd's. For users, we have a fast
* lookup table which can find a user by file descriptor, so
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index f910802bb..3e0b3814d 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -41,6 +41,7 @@ SocketEngine::SocketEngine()
#ifdef USE_KQUEUE
EngineHandle = kqueue();
#endif
+ CurrentSetSize = 0;
}
SocketEngine::~SocketEngine()
@@ -99,7 +100,8 @@ bool SocketEngine::AddFd(int fd, bool readable, char type)
return false;
}
#endif
-return true;
+ CurrentSetSize++;
+ return true;
}
bool SocketEngine::DelFd(int fd)
@@ -138,10 +140,37 @@ bool SocketEngine::DelFd(int fd)
return false;
}
#endif
+ CurrentSetSize--;
ref[fd] = 0;
return true;
}
+int SocketEngine::GetMaxFds()
+{
+#ifdef USE_SELECT
+ return FD_SETSIZE;
+#endif
+#ifdef USE_KQUEUE
+ return MAX_DESCRIPTORS;
+#endif
+#ifdef USE_EPOLL
+ return MAX_DESCRIPTORS;
+#endif
+}
+
+int SocketEngine::GetRemainingFds()
+{
+#ifdef USE_SELECT
+ return FD_SETSIZE - CurrentSetSize;
+#endif
+#ifdef USE_KQUEUE
+ return MAX_DESCRIPTORS - CurrentSetSize;
+#endif
+#ifdef USE_EPOLL
+ return MAX_DESCRIPTORS - CurrentSetSize;
+#endif
+}
+
int SocketEngine::Wait(int* fdlist)
{
int result = 0;