/** Look up the fd limit using rlimit. */
static void LookupMaxFds();
+ /** Terminates the program when the socket engine fails to initialize. */
+ static void InitError();
+
static void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
/** Add an event handler to the base socket engine. AddFd(EventHandler*, int) should call this.
*/
+#include "exitcodes.h"
#include "inspircd.h"
+#include <iostream>
+
/** Reference table, contains all current handlers
**/
std::vector<EventHandler*> SocketEngine::ref;
{
}
+void SocketEngine::InitError()
+{
+ std::cerr << con_red << "FATAL ERROR!" << con_reset << " Socket engine initialization failed. " << strerror(errno) << '.' << std::endl;
+ ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE);
+}
+
void SocketEngine::LookupMaxFds()
{
struct rlimit limits;
#include "inspircd.h"
-#include "exitcodes.h"
#include <sys/epoll.h>
#include <sys/resource.h>
-#include <iostream>
/** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll().
*/
// 128 is not a maximum, just a hint at the eventual number of sockets that may be polled,
// and it is completely ignored by 2.6.8 and later kernels, except it must be larger than zero.
EngineHandle = epoll_create(128);
-
if (EngineHandle == -1)
- {
- ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Could not initialize socket engine: %s", strerror(errno));
- ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Your kernel probably does not have the proper features. This is a fatal error, exiting now.");
- std::cout << "ERROR: Could not initialize epoll socket engine: " << strerror(errno) << std::endl;
- std::cout << "ERROR: Your kernel probably does not have the proper features. This is a fatal error, exiting now." << std::endl;
- ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE);
- }
+ InitError();
}
void SocketEngine::RecoverFromFork()
#include "inspircd.h"
-#include "exitcodes.h"
+
#include <sys/types.h>
#include <sys/event.h>
#include <sys/time.h>
-#include <iostream>
#include <sys/sysctl.h>
/** A specialisation of the SocketEngine class, designed to use BSD kqueue().
*/
EngineHandle = kqueue();
if (EngineHandle == -1)
- {
- ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
- ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: this is a fatal error, exiting now.");
- std::cout << "ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features." << std::endl;
- std::cout << "ERROR: this is a fatal error, exiting now." << std::endl;
- ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE);
- }
+ InitError();
}
/** Shutdown the kqueue engine
*/
-#include "exitcodes.h"
#include "inspircd.h"
#include <sys/poll.h>