diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-29 14:03:14 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-29 14:03:14 +0000 |
commit | 024f972eb1ffc67bb32b2f083955199cbd6ecdde (patch) | |
tree | e5d0fe90854d116e93d1ce45849e0e8586d02f89 /src/socketengine.cpp | |
parent | b0cb12952a378d4d3717d3a5556325a15be1de0a (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/socketengine.cpp')
-rw-r--r-- | src/socketengine.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
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; |