diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-02-13 14:52:09 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-02-13 14:52:09 +0000 |
commit | 753f492c4f71bd4445a77e292370b6e7735010a9 (patch) | |
tree | c396fcc4fd483e815169925e7924ba043bb9c1fc /src | |
parent | 04ea7de4a7a9ab7732926496e3a13d1fa659aec8 (diff) |
Fix kqueue to not report 0 maximum open sockets
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12449 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/socketengines/socketengine_kqueue.cpp | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index e7d7e4283..63a877238 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -16,30 +16,6 @@ #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> -/* +------------------------------------+ - * | Inspire Internet Relay Chat Daemon | - * +------------------------------------+ - * - * InspIRCd: (C) 2002-2010 InspIRCd Development Team - * See: http://wiki.inspircd.org/Credits - * - * This program is free but copyrighted software; see - * the file COPYING for details. - * - * --------------------------------------------------- - */ - -#ifndef __SOCKETENGINE_KQUEUE__ -#define __SOCKETENGINE_KQUEUE__ - -#include <vector> -#include <string> -#include <map> -#include "inspircd_config.h" -#include "inspircd.h" -#include <sys/types.h> -#include <sys/event.h> -#include <sys/time.h> #include "socketengine.h" /** A specialisation of the SocketEngine class, designed to use FreeBSD kqueue(). @@ -69,13 +45,25 @@ public: virtual void RecoverFromFork(); }; -#endif - #include <sys/sysctl.h> KQueueEngine::KQueueEngine() { MAX_DESCRIPTORS = 0; + 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); + if (MAX_DESCRIPTORS <= 0) + { + 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); + } + this->RecoverFromFork(); ke_list = new struct kevent[GetMaxFds()]; ref = new EventHandler* [GetMaxFds()]; |