+private:
+ /** These are used by epoll() to hold socket events
+ */
+ port_event_t* events;
+ int EngineHandle;
+public:
+ /** Create a new PortsEngine
+ */
+ PortsEngine();
+ /** Delete a PortsEngine
+ */
+ virtual ~PortsEngine();
+ virtual bool AddFd(EventHandler* eh, int event_mask);
+ virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
+ virtual void DelFd(EventHandler* eh);
+ virtual int DispatchEvents();
+ virtual std::string GetName();
+};
+
+#endif
+
+
+#include <ulimit.h>
+
+PortsEngine::PortsEngine()
+{
+ int max = ulimit(4, 0);
+ if (max > 0)
+ {
+ MAX_DESCRIPTORS = max;
+ }
+ else
+ {
+ ServerInstance->Logs->Log("SOCKET", DEFAULT, "ERROR: Can't determine maximum number of open sockets!");
+ std::cout << "ERROR: Can't determine maximum number of open sockets!" << std::endl;
+ ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE);
+ }