diff options
author | Peter Powell <petpow@saberuk.com> | 2012-12-20 00:34:38 +0000 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2012-12-25 18:39:03 +0100 |
commit | 8540f6af60f652f52b9c6b47109205da6667d032 (patch) | |
tree | 321812aa115ee2a27cc20e25cdc11a04795f099e /src/socketengines | |
parent | 618d13196dafd670a6c136a05ab27c007744494a (diff) |
Fix the poll socket engine on BSD's other than FreeBSD.
Diffstat (limited to 'src/socketengines')
-rw-r--r-- | src/socketengines/socketengine_poll.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 6a385c8d8..5c361a0cb 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -76,15 +76,28 @@ public: #endif -#include <ulimit.h> -#ifdef __FreeBSD__ +#ifdef BSD #include <sys/sysctl.h> +#else + #include <ulimit.h> #endif PollEngine::PollEngine() { CurrentSetSize = 0; -#ifndef __FreeBSD__ +#ifdef BSD + int mib[2]; + size_t len; + + mib[0] = CTL_KERN; +#ifdef KERN_MAXFILESPERPROC + mib[1] = KERN_MAXFILESPERPROC; +#else + mib[1] = KERN_MAXFILES; +#endif + len = sizeof(MAX_DESCRIPTORS); + sysctl(mib, 2, &MAX_DESCRIPTORS, &len, NULL, 0); +#else int max = ulimit(4, 0); if (max > 0) { @@ -96,14 +109,6 @@ PollEngine::PollEngine() std::cout << "ERROR: Can't determine maximum number of open sockets: " << strerror(errno) << std::endl; ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE); } -#else - int mib[2]; - size_t len; - - mib[0] = CTL_KERN; - mib[1] = KERN_MAXFILES; - len = sizeof(MAX_DESCRIPTORS); - sysctl(mib, 2, &MAX_DESCRIPTORS, &len, NULL, 0); #endif ref = new EventHandler* [GetMaxFds()]; |