diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-01-14 18:54:07 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-01-14 18:54:07 +0000 |
commit | d13dd19906631e88165ad51073ad1054b2d16dfc (patch) | |
tree | 440b1263296f8961d238f3b7f3f1617afed103eb /src | |
parent | 33457adb681562e8b66ba417e3791510adfd0c1e (diff) |
This should work, but not sure on these defines in poll socketengine
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10961 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/socketengines/socketengine_poll.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 3ed284166..d32d31cc4 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.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. * * --------------------------------------------------- */ @@ -99,6 +99,7 @@ bool PollEngine::DelFd(EventHandler* eh, bool force) int PollEngine::GetMaxFds() { +#ifdef LINUX if (MAX_DESCRIPTORS) return MAX_DESCRIPTORS; @@ -110,11 +111,28 @@ int PollEngine::GetMaxFds() } else { - ServerInstance->Logs->Log("SOCKET", DEFAULT, "ERROR: Can't determine maximum number of open sockets!"); - printf("ERROR: Can't determine maximum number of open sockets!\n"); + MAX_DESCRIPTORS = 0; + ServerInstance->Logs->Log("SOCKET", DEFAULT, "ERROR: Can't determine maximum number of open sockets: %s", strerror(errno)); + printf("ERROR: Can't determine maximum number of open sockets: %s\n", strerror(errno))); ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE); } return 0; +#endif +#ifdef FREEBSD + if (!MAX_DESCRIPTORS) + { + int mib[2], maxfiles; + size_t len; + + mib[0] = CTL_KERN; + mib[1] = KERN_MAXFILES; + len = sizeof(maxfiles); + sysctl(mib, 2, &maxfiles, &len, NULL, 0); + MAX_DESCRIPTORS = maxfiles; + return maxfiles; + } + return MAX_DESCRIPTORS; +#endif } int PollEngine::GetRemainingFds() |