]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_ports.cpp
Merge pull request #338 from ChrisTX/insp20+iostream
[user/henk/code/inspircd.git] / src / socketengines / socketengine_ports.cpp
index 5642a722377f0c4118bb9425ef4282aa159c3b1e..9a86c47d0cd915b6f597a35a026c41e91ec22ad3 100644 (file)
@@ -1,22 +1,29 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
  *
- *  InspIRCd: (C) 2002-2010 InspIRCd Development Team
- * See: http://wiki.inspircd.org/Credits
+ *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
+ *   Copyright (C) 2007-2008 Craig Edwards <craigedwards@brainbox.cc>
  *
- * This program is free but copyrighted software; see
- *         the file COPYING for details.
+ * This file is part of InspIRCd.  InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
  *
- * ---------------------------------------------------
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+
 #include "inspircd.h"
 #include "exitcodes.h"
 #include <port.h>
 
-#ifndef __SOCKETENGINE_PORTS__
-#define __SOCKETENGINE_PORTS__
+#ifndef SOCKETENGINE_PORTS
+#define SOCKETENGINE_PORTS
 
 #ifndef __sun
 # error You need Solaris 10 or later to make use of this code.
@@ -29,6 +36,7 @@
 #include "inspircd.h"
 #include "socketengine.h"
 #include <port.h>
+#include <iostream>
 
 /** A specialisation of the SocketEngine class, designed to use solaris 10 I/O completion ports
  */
@@ -40,7 +48,6 @@ private:
        port_event_t* events;
 public:
        /** Create a new PortsEngine
-        * @param Instance The creator of this object
         */
        PortsEngine();
        /** Delete a PortsEngine
@@ -48,7 +55,7 @@ public:
        virtual ~PortsEngine();
        virtual bool AddFd(EventHandler* eh, int event_mask);
        void OnSetEvent(EventHandler* eh, int old_event, int new_event);
-       virtual bool DelFd(EventHandler* eh, bool force = false);
+       virtual void DelFd(EventHandler* eh);
        virtual int DispatchEvents();
        virtual std::string GetName();
        virtual void WantWrite(EventHandler* eh);
@@ -65,12 +72,11 @@ PortsEngine::PortsEngine()
        if (max > 0)
        {
                MAX_DESCRIPTORS = max;
-               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");
+               std::cout << "ERROR: Can't determine maximum number of open sockets!" << std::endl;
                ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
        }
        EngineHandle = port_create();
@@ -79,8 +85,8 @@ PortsEngine::PortsEngine()
        {
                ServerInstance->Logs->Log("SOCKET",SPARSE,"ERROR: Could not initialize socket engine: %s", strerror(errno));
                ServerInstance->Logs->Log("SOCKET",SPARSE,"ERROR: This is a fatal error, exiting now.");
-               printf("ERROR: Could not initialize socket engine: %s\n", strerror(errno));
-               printf("ERROR: This is a fatal error, exiting now.\n");
+               std::cout << "ERROR: Could not initialize socket engine: " << strerror(errno) << std::endl;
+               std::cout << "ERROR: This is a fatal error, exiting now." << std::endl;
                ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
        }
        CurrentSetSize = 0;
@@ -131,11 +137,11 @@ void PortsEngine::WantWrite(EventHandler* eh, int old_mask, int new_mask)
                port_associate(EngineHandle, PORT_SOURCE_FD, eh->GetFd(), mask_to_events(new_mask), eh);
 }
 
-bool PortsEngine::DelFd(EventHandler* eh, bool force)
+void PortsEngine::DelFd(EventHandler* eh)
 {
        int fd = eh->GetFd();
        if ((fd < 0) || (fd > GetMaxFds() - 1))
-               return false;
+               return;
 
        port_dissociate(EngineHandle, PORT_SOURCE_FD, fd);