summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-02-25 13:01:42 +0100
committerMax Kellermann <max@musicpd.org>2019-02-25 13:08:33 +0100
commit44422b2b2f0a0bf29ffadfac0814b9bcd17db564 (patch)
tree119cbf3fecf2a3b313a8b04d3225bcc6ebb280ff /src
parentf10afd38b5b94c7767e00701337d8f6aa5bf5222 (diff)
event/ServerSocket, config/Net: abstract socket support
Diffstat (limited to 'src')
-rw-r--r--src/config/Net.cxx4
-rw-r--r--src/event/ServerSocket.cxx16
-rw-r--r--src/event/ServerSocket.hxx12
3 files changed, 32 insertions, 0 deletions
diff --git a/src/config/Net.cxx b/src/config/Net.cxx
index 4c0e6f3b5..afba81f9d 100644
--- a/src/config/Net.cxx
+++ b/src/config/Net.cxx
@@ -29,6 +29,10 @@ ServerSocketAddGeneric(ServerSocket &server_socket, const char *address, unsigne
server_socket.AddPort(port);
} else if (address[0] == '/' || address[0] == '~') {
server_socket.AddPath(ParsePath(address));
+#ifdef __linux__
+ } else if (address[0] == '@') {
+ server_socket.AddAbstract(address);
+#endif
} else {
server_socket.AddHost(address, port);
}
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