From: Hwankyu Jhun Date: Fri, 10 Jan 2025 10:32:27 +0000 (+0900) Subject: Change socket file name X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Fref%2Ffor%2Ftizen;p=platform%2Fcore%2Fappfw%2Flaunchpad.git Change socket file name This patch changes the file name to the previous socket file for backward compatibility. Change-Id: I5717e1c9093a9b2db2ea1715144014bbba6a64b2 Signed-off-by: Hwankyu Jhun --- diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 4e9e99fd..8ee59fd5 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -59,6 +59,19 @@ const int kReceivedBufferSize = 131071; const int kMaxPendingConnection = 128; const uid_t kRegularUidMin = 5000; +void CreatePreviousSocketFile() { + auto path = std::format("{}/{}/.launchpad-process-pool-sock", + kRunAulDaemonsPath, getuid()); + int fd = open(path.c_str(), O_RDWR | O_CREAT, + S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + if (fd != 0) { + _E("open() is failed. errno=%d", errno); + return; + } + + close(fd); +} + int GetLaunchpadFdFromSystemd() { auto path = std::format("{}-{}", kLaunchpadProcessPoolSock, getuid()); path[0] = '\0'; @@ -85,36 +98,21 @@ int GetLaunchpadFdFromEnvironment() { } ServerSocket* GetLaunchpadSocket() { - int marker; - char path[PATH_MAX] = {0,}; - - //TODO(Abstract Socket Issue): file-based socket check int fd = GetLaunchpadFdFromSystemd(); if (fd < 0) fd = GetLaunchpadFdFromEnvironment(); if (fd > -1) { - snprintf(path, PATH_MAX, "%s%d/%s", - kRunAulDaemonsPath, getuid(), kLaunchpadProcessPoolSock); - marker = open(path, O_RDWR | O_CREAT, - S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - close(marker); - + CreatePreviousSocketFile(); return new ServerSocket(fd); - } else { - auto* socket = new ServerSocket(); - const std::string endpoint = std::string(kLaunchpadProcessPoolSock) + "-" + - std::to_string(getuid()); - socket->Bind(endpoint); - socket->SetReceiveBufferSize(kReceivedBufferSize); - socket->Listen(kMaxPendingConnection); + } - snprintf(path, PATH_MAX, "%s%d/%s", - kRunAulDaemonsPath, getuid(), kLaunchpadProcessPoolSock); - marker = open(path, O_RDWR | O_CREAT, - S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - close(marker); + auto* socket = new ServerSocket(); + auto endpoint = std::format("{}-{}", kLaunchpadProcessPoolSock, getuid()); + socket->Bind(endpoint); + socket->SetReceiveBufferSize(kReceivedBufferSize); + socket->Listen(kMaxPendingConnection); - return socket; - } + CreatePreviousSocketFile(); + return socket; } void PrintAppInfo(const AppInfo* app_info) {