diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-02 17:08:09 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2008-04-02 17:08:09 +0000 |
commit | 2db77cda56947d4ee0f913c8082f6607855ca713 (patch) | |
tree | f7f83c80f62adc4e3eb0f9f3b680229466c4352e /src/socketengines/socketengine_select.cpp | |
parent | d9d33e7246baf59241d083eb2c253e729390d205 (diff) |
Automatic detection and allocation of max fds. No longer needs recompile to change, just adjust it in your kernel or whatever and restart insp.
Please note that select and iocp socket engines do not support detection and are always set to FD_SETSIZE and 10240 descriptors respectively.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9263 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengines/socketengine_select.cpp')
-rw-r--r-- | src/socketengines/socketengine_select.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index 055637890..5a5d61147 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -6,7 +6,7 @@ * See: http://www.inspircd.org/wiki/index.php/Credits * * This program is free but copyrighted software; see - * the file COPYING for details. + * the file COPYING for details. * * --------------------------------------------------- */ @@ -22,17 +22,22 @@ SelectEngine::SelectEngine(InspIRCd* Instance) : SocketEngine(Instance) { EngineHandle = 0; CurrentSetSize = 0; + + writeable = new bool [GetMaxFds()]; memset(writeable, 0, sizeof(writeable)); + ref = new EventHandler* [GetMaxFds()]; + memset(ref, 0, GetMaxFds() * sizeof(EventHandler*)); } SelectEngine::~SelectEngine() { + delete[] ref; } bool SelectEngine::AddFd(EventHandler* eh) { int fd = eh->GetFd(); - if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + if ((fd < 0) || (fd > GetMaxFds() - 1)) return false; if (GetRemainingFds() <= 1) @@ -58,7 +63,7 @@ bool SelectEngine::DelFd(EventHandler* eh, bool force) { int fd = eh->GetFd(); - if ((fd < 0) || (fd > MAX_DESCRIPTORS)) + if ((fd < 0) || (fd > GetMaxFds() - 1)) return false; std::map<int,int>::iterator t = fds.find(fd); @@ -79,7 +84,7 @@ int SelectEngine::GetMaxFds() int SelectEngine::GetRemainingFds() { - return FD_SETSIZE - CurrentSetSize; + return GetMaxFds() - CurrentSetSize; } int SelectEngine::DispatchEvents() @@ -87,7 +92,7 @@ int SelectEngine::DispatchEvents() int result = 0; timeval tval; int sresult = 0; - EventHandler* ev[MAX_DESCRIPTORS]; + EventHandler* ev[GetMaxFds()]; socklen_t codesize; int errcode; |