From 44422b2b2f0a0bf29ffadfac0814b9bcd17db564 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 25 Feb 2019 13:01:42 +0100 Subject: event/ServerSocket, config/Net: abstract socket support --- src/event/ServerSocket.cxx | 16 ++++++++++++++++ src/event/ServerSocket.hxx | 12 ++++++++++++ 2 files changed, 28 insertions(+) (limited to 'src/event') diff --git a/src/event/ServerSocket.cxx b/src/event/ServerSocket.cxx index 6f675dddc..73e070c9e 100644 --- a/src/event/ServerSocket.cxx +++ b/src/event/ServerSocket.cxx @@ -396,3 +396,19 @@ ServerSocket::AddPath(AllocatedPath &&path) #endif /* !HAVE_UN */ } + +#ifdef __linux__ + +void +ServerSocket::AddAbstract(const char *name) +{ + assert(name != nullptr); + assert(*name == '@'); + + AllocatedSocketAddress address; + address.SetLocal(name); + + AddAddress(std::move(address)); +} + +#endif diff --git a/src/event/ServerSocket.hxx b/src/event/ServerSocket.hxx index 22edff428..8a36dded7 100644 --- a/src/event/ServerSocket.hxx +++ b/src/event/ServerSocket.hxx @@ -99,6 +99,18 @@ public: */ void AddPath(AllocatedPath &&path); +#ifdef __linux__ + /** + * Add a listener on an abstract local socket (Linux specific). + * + * Throws on error. + * + * @param name the abstract socket name, starting with a '@' + * instead of a null byte + */ + void AddAbstract(const char *name); +#endif + /** * Add a socket descriptor that is accepting connections. After this * has been called, don't call server_socket_open(), because the -- cgit v1.2.3