summaryrefslogtreecommitdiff
path: root/src/socketengines
diff options
context:
space:
mode:
Diffstat (limited to 'src/socketengines')
-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()