14#include <unordered_map>
17#include "UnixSession.hpp"
19#include <dfx-fdwatch/PollerFd.hpp>
20#include <dfx-fdwatch/Timer.hpp>
22#include <dfx-utilities/FileSystem.hpp>
163 bool isListening() const noexcept {
return _serverSocket.isRegistered(); }
174 void _onTimerTimeout();
175 void _serverSocketReadyRead(FdWatch::EventTriggers events);
176 void _onSessionReadyRead(
UnixSessionPtr session, FdWatch::EventTriggers events);
182 bool _isInit =
false;
187 std::mutex _sessionMutex;
188 std::unordered_map<FdWatch::BorrowedFd, UnixSessionPtr> _sessions;
Convenience macros to explicitly control copy and move semantics.
Event interest and trigger flags for file-descriptor watching (Linux/epoll).
RAII wrapper for the registration of a FD in a Poller.
Definition PollerFd.hpp:42
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
FD-integrated timer utility (timerfd-backed).
Definition Timer.hpp:52
JSON command router for the Unix domain socket control protocol.
Definition UnixRouter.hpp:78
void stop() noexcept
Stop listening and remove the socket file from the filesystem.
~UnixServer()
Stop listening and release resources.
void listen()
Start listening on the configured unix socket path.
DISABLE_COPY_AND_MOVE(UnixServer)
UnixServer are not copyable and not movable.
UnixServer(Utils::SystemConfig &sysConfig, FdWatch::Poller &poller, UnixRouter &router, std::string const &defaultSocketPath="/var/run/dfx.sock")
Construct a Unix control server and register SystemConfig entries.
bool isListening() const noexcept
Whether the server socket is currently registered and listening.
Definition UnixServer.hpp:163
void terminateSession(UnixSessionPtr session)
Terminate and forget a session.
System configuration registry with typed values, entry metadata, and change callbacks.
Definition SystemConfig.hpp:81
Definition SocketClient.hpp:23
Definition BaseCommandHandler.hpp:16
std::shared_ptr< UnixSession > UnixSessionPtr
Shared ownership pointer type for sessions.
Definition BaseCommandHandler.hpp:20
Definition SystemConfigCommandHandler.hpp:15
Server configuration values (mostly controlled via Utils::SystemConfig).
Definition UnixServer.hpp:100
std::chrono::milliseconds inactivityTimeout
Inactivity timeout for sessions.
Definition UnixServer.hpp:109
uint32_t backlog
Backlog value used for listen(2).
Definition UnixServer.hpp:103
uint64_t consecutiveErrCountBeforeClose
Maximum number of consecutive error responses sent to a client before closing.
Definition UnixServer.hpp:125
uint32_t permission
Permission mask applied to the socket file (octal, e.g. 0600). Must be <= 0777.
Definition UnixServer.hpp:102
uint64_t errCountBeforeClose
Maximum number of total error responses sent to a client before closing. Value 0 disables this limit.
Definition UnixServer.hpp:119
std::chrono::milliseconds timeoutAccuracy
Periodic timer interval for timeout/error checks.
Definition UnixServer.hpp:115
fs::path socket
Path to the unix domain socket file.
Definition UnixServer.hpp:101