From 46242bf71b58dc4c563efdc1bb3a0589b0a6fdfc Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 2 Apr 2008 17:55:29 +0000 Subject: 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 --- src/socketengines/socketengine_kqueue.cpp | 24 +++++++++++------------- 1 file 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() -- cgit v1.2.3