26 #include <gnutls/gnutls.h>
61 bool run(
double max_time);
76 max_open_fd_reached =
true;
78 std::set<Socket *> findSockByTask(
const Task *t)
const;
90 for (
auto it : connectionStore)
91 if (it.second == conn)
108 const std::string &key_path,
const std::string &password);
117 static volatile bool yield_called;
118 static bool max_open_fd_reached;
119 void handleMaxOpenFdReached();
120 void killConnection(
int fd);
124 bool reclaimConnections();
127 int setFds(fd_set &r, fd_set &w, fd_set &e);
129 bool fatalSelectError();
131 void doFds(
const fd_set &r,
const fd_set &w,
const fd_set &e,
int max);
134 std::map<int, Socket *> connectionStore;
140 std::multimap<std::string, int> keepaliveCache;
142 std::map<int, gnutls_session_t> tls_session_cache;
143 std::string ca_bundle;
144 std::map<std::string, unsigned int> tls_crt_map;
147 std::vector<gnutls_certificate_credentials_t> x509_cred;
148 gnutls_priority_t priority_cache;
The network engine.
Definition: engine.h:33
void childProcessCloseSockets()
Call this in child process to close all redundant sockets after fork.
Definition: engine.cpp:180
bool tlsSetKey(ServerSocket *conn, const std::string &crt_path, const std::string &key_path, const std::string &password)
Use SSL certificate for a listening socket.
Definition: engine.cpp:73
void terminate(unsigned int max_time_ms)
Definition: engine.cpp:187
bool connActive(const Socket *conn) const
Definition: engine.h:89
void resetDeadline(const TimePoint &t)
Call this to make the Engine::run method return earlier.
Definition: engine.h:97
bool wakeUpConnection(SocketConnection *s)
Wake up connection s if it is idle, return false otherwise.
Definition: engine.cpp:587
~Engine()
Will kill all remaining connections.
Definition: engine.cpp:47
void deleteConnByTask(const Task *task)
Remove all connections owned by the task.
Definition: engine.cpp:594
bool setCABundle(const std::string &path)
Set path to file containing chain of trust for SSL certificate.
Definition: engine.cpp:63
static void yield()
Call this to make the Engine::run method return prematurely.
Definition: engine.h:67
static void notifyOutOfFds()
Call this to enter a recovery mode if no more file descriptors could be created.
Definition: engine.h:74
bool run(double max_time)
Run the "event loop" for at most max_time seconds.
Definition: engine.cpp:334
void wakeUpByTask(Task *t)
Wake up all idle connections belonging to t:
Definition: engine.cpp:580
A simple logger. All classes that want to write to the global log file should inherit from this class...
Definition: logger.h:86
std::string label() const
Return the object's log label.
Definition: logger.h:251
Listen on a single socket for incoming connections.
Definition: serversocket.h:15
This class implements low-level socket connection operations. Inherit from it to implement protocols ...
Definition: socketconnection.h:47
This is a slave to the Engine class. You can't use it directly, only through its subclasses,...
Definition: socket.h:18
The purpose of a task is to manage socket connections, and/or to execute timers.
Definition: task.h:39
Measure elapsed time during execution, for example by timer events.