summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-02 17:55:29 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-02 17:55:29 +0000
commit46242bf71b58dc4c563efdc1bb3a0589b0a6fdfc (patch)
tree564297e04f2337180d3bf191938ea9c948790967 /src
parent5a33229824ef8e89648083ebb85962e19b0c91a3 (diff)
Proper sysctl stuff to work with bsd. It seems that the uname value 4 is linux specific and they dont even have a const for it there!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9268 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/socketengines/socketengine_kqueue.cpp24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp
index 63a1844cb..0fb14c29f 100644
--- a/src/socketengines/socketengine_kqueue.cpp
+++ b/src/socketengines/socketengine_kqueue.cpp
@@ -121,22 +121,20 @@ void KQueueEngine::WantWrite(EventHandler* eh)
int KQueueEngine::GetMaxFds()
{
- if (MAX_DESCRIPTORS)
- return MAX_DESCRIPTORS;
-
- int max = ulimit(4, 0);
- if (max > 0)
+ if (!MAX_DESCRIPTORS)
{
- MAX_DESCRIPTORS = max;
+ 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 max;
}
- 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");
- ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
- }
- return 0;
+ return MAX_DESCRIPTORS;
}
int KQueueEngine::GetRemainingFds()