summaryrefslogtreecommitdiff
path: root/src/socketengines/socketengine_poll.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-01-14 18:54:07 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-01-14 18:54:07 +0000
commitd13dd19906631e88165ad51073ad1054b2d16dfc (patch)
tree440b1263296f8961d238f3b7f3f1617afed103eb /src/socketengines/socketengine_poll.cpp
parent33457adb681562e8b66ba417e3791510adfd0c1e (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/socketengines/socketengine_poll.cpp')
-rw-r--r--src/socketengines/socketengine_poll.cpp24
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()