summaryrefslogtreecommitdiff
path: root/Userland/Services/ConfigServer
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-12-06 17:54:11 +0100
committerAndreas Kling <kling@serenityos.org>2021-12-06 19:22:16 +0100
commit6d0f504822bad8baaed79ed55e43e7a253efa187 (patch)
tree5d0ff3c6fc615addc006edd4c8e0219fcfaead61 /Userland/Services/ConfigServer
parent81047d8f9cb092fa3ef83c4e06f1dfd8f65173be (diff)
downloadserenity-6d0f504822bad8baaed79ed55e43e7a253efa187.zip
LibIPC: Add IPC::MultiServer convenience class
This encapsulates what our multi-client IPC servers typically do on startup: 1. Create a Core::LocalServer 2. Take over a listening socket file descriptor from SystemServer 3. Set up an accept handler for incoming connections IPC::MultiServer does all this for you! All you have to do is provide the relevant client connection type as a template argument.
Diffstat (limited to 'Userland/Services/ConfigServer')
-rw-r--r--Userland/Services/ConfigServer/main.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/Userland/Services/ConfigServer/main.cpp b/Userland/Services/ConfigServer/main.cpp
index cde261b8a7..344e940a94 100644
--- a/Userland/Services/ConfigServer/main.cpp
+++ b/Userland/Services/ConfigServer/main.cpp
@@ -5,9 +5,9 @@
*/
#include "ClientConnection.h"
-#include <LibCore/LocalServer.h>
#include <LibCore/StandardPaths.h>
#include <LibCore/System.h>
+#include <LibIPC/MultiServer.h>
#include <LibMain/Main.h>
ErrorOr<int> serenity_main(Main::Arguments)
@@ -18,13 +18,6 @@ ErrorOr<int> serenity_main(Main::Arguments)
Core::EventLoop event_loop;
- auto server = TRY(Core::LocalServer::try_create());
- TRY(server->take_over_from_system_server());
- server->on_accept = [&](auto client_socket) {
- static int s_next_client_id = 0;
- int client_id = ++s_next_client_id;
- (void)IPC::new_client_connection<ConfigServer::ClientConnection>(move(client_socket), client_id);
- };
-
+ auto server = TRY(IPC::MultiServer<ConfigServer::ClientConnection>::try_create());
return event_loop.exec();
}