X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=include%2Fsocketengine.h;h=a788618a27a47ceb6a5d6f6c2018c40396ccb26d;hb=2329d59b09cdc05b0b403f7d313df65492e1813b;hp=ecb8fa96e7e0287e91671dcf8ea006993cee99b7;hpb=024f972eb1ffc67bb32b2f083955199cbd6ecdde;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/include/socketengine.h b/include/socketengine.h index ecb8fa96e..a788618a2 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -2,7 +2,7 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2005 ChatSpike-Dev. + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. * E-mail: * * @@ -23,15 +23,6 @@ #include "inspircd_config.h" #include "globals.h" #include "inspircd.h" -#ifdef USE_EPOLL -#include -#define EP_DELAY 5 -#endif -#ifdef USE_KQUEUE -#include -#include -#include -#endif /** * Each of these values represents a socket @@ -49,7 +40,7 @@ const char X_ESTAB_DNS = 4; * To indicate that a socket is readable, we * mask its top bit with this X_READBIT value. * The socket engine can handle two types of - * socket, readable and writeable (error sockets + * socket, readable and writeable (;error sockets * are dealt with when read() and write() return * negative or zero values). */ @@ -63,22 +54,22 @@ const char X_READBIT = 0x80; * from system to system and upon the config * settings chosen by the server admin. The current * version supports select, epoll and kqueue. + * The configure script will enable a socket engine + * based upon what OS is detected, and will derive + * a class from SocketEngine based upon what it finds. + * The derived classes file will also implement a + * classfactory, SocketEngineFactory, which will + * create a derived instance of SocketEngine using + * polymorphism so that the core and modules do not + * have to be aware of which SocketEngine derived + * class they are using. */ -class SocketEngine { - +class SocketEngine : public Extensible +{ +protected: int EngineHandle; /* Handle to the socket engine if needed */ -#ifdef USE_SELECT - std::map fds; /* List of file descriptors being monitored */ - fd_set wfdset, rfdset; /* Readable and writeable sets for select() */ -#endif -#ifdef USE_KQUEUE - struct kevent ke_list[65535]; /* Up to 64k sockets for kqueue */ - struct timespec ts; /* kqueue delay value */ -#endif -#ifdef USE_EPOLL - struct epoll_event events[65535]; /* Up to 64k sockets for epoll */ -#endif - + int CurrentSetSize; /* Current number of descriptors in the engine */ + char ref[MAX_DESCRIPTORS]; /* Reference table */ public: /** Constructor @@ -95,7 +86,7 @@ public: * The destructor transparently tidies up * any resources used by the socket engine. */ - ~SocketEngine(); + virtual ~SocketEngine(); /** Add a file descriptor to the engine * Use AddFd to add a file descriptor to the @@ -106,7 +97,7 @@ public: * or write events (there is currently no * need for support of both). */ - bool AddFd(int fd, bool readable, char type); + virtual bool AddFd(int fd, bool readable, char type); /** Returns the type value for this file descriptor * This function masks off the X_READBIT value @@ -123,19 +114,24 @@ public: /** Returns the maximum number of file descriptors * you may store in the socket engine at any one time. */ - int GetMaxFds(); + virtual int GetMaxFds(); /** Returns the number of file descriptor slots * which are available for storing fds. */ - int GetRemainingFds(); + virtual int GetRemainingFds(); - /** Delete a file descriptor f rom the engine + /** Delete a file descriptor from the engine * This function call deletes a file descriptor * from the engine, returning true if it succeeded * and false if it failed. */ - bool DelFd(int fd); + virtual bool DelFd(int fd); + + /** Returns true if a socket exists in the socket + * engine's list. + */ + bool HasFd(int fd); /** Waits for an event. * Please note that this doesnt wait long, only @@ -143,13 +139,13 @@ public: * of active file descriptors in the vector * fdlist which the core may then act upon. */ - int Wait(int* fdlist); + virtual int Wait(int* fdlist); /** Returns the socket engines name * This returns the name of the engine for use * in /VERSION responses. */ - std::string GetName(); + virtual std::string GetName(); }; #endif