From 753f492c4f71bd4445a77e292370b6e7735010a9 Mon Sep 17 00:00:00 2001 From: danieldg Date: Sat, 13 Feb 2010 14:52:09 +0000 Subject: 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 --- src/socketengines/socketengine_kqueue.cpp | 40 +++++++++++-------------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'src/socketengines') 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 #include #include -/* +------------------------------------+ - * | 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 -#include -#include -#include "inspircd_config.h" -#include "inspircd.h" -#include -#include -#include #include "socketengine.h" /** A specialisation of the SocketEngine class, designed to use FreeBSD kqueue(). @@ -69,13 +45,25 @@ public: virtual void RecoverFromFork(); }; -#endif - #include 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()]; -- cgit v1.2.3