summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2022-08-07 16:48:26 +0200
committerLinus Groh <mail@linusgroh.de>2022-08-14 21:52:35 +0100
commita13ffffbec78f1111af9c9df94897ac5fa480637 (patch)
tree388c27d8dc8c63bf0f36939b45ff79400aa5275e /Userland/Services
parentb14fedd02a79f00cd092bded7cf37a58af3f90ab (diff)
downloadserenity-a13ffffbec78f1111af9c9df94897ac5fa480637.zip
SystemServer: Unlink before binding a new socket
Prevent "Address already in use" issues when restarting a service.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/SystemServer/Service.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp
index f2d1c2dde2..90d677af18 100644
--- a/Userland/Services/SystemServer/Service.cpp
+++ b/Userland/Services/SystemServer/Service.cpp
@@ -35,6 +35,10 @@ ErrorOr<void> Service::setup_socket(SocketDescriptor& socket)
{
VERIFY(socket.fd == -1);
+ // Note: The purpose of this syscall is to remove potential left-over of previous portal.
+ // The return value is discarded as sockets are not always there, and unlinking a non-existent path is considered as a failure.
+ (void)Core::System::unlink(socket.path);
+
TRY(Core::Directory::create(LexicalPath(socket.path).parent(), Core::Directory::CreateDirectories::Yes));
// Note: we use SOCK_CLOEXEC here to make sure we don't leak every socket to