From: Changgyu Choi Date: Mon, 9 Jun 2025 01:55:01 +0000 (+0900) Subject: Delete loader .ready file on context disposal X-Git-Tag: accepted/tizen/unified/20250611.024021~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d833ac904db0d4ae9039b113ba7654796e30734c;p=platform%2Fcore%2Fappfw%2Flaunchpad.git Delete loader .ready file on context disposal The .ready file signals that the loader is active and ready. This change ensures the .ready file is removed when the LoaderContext is disposed. By doing so, the presence or absence of the .ready file accurately indicates the loader's current availability, allowing its operational status to be determined by checking for the file's existence. Change-Id: If4826b981c278e6a93750766e671a00e6c0efd1b Signed-off-by: Changgyu Choi --- diff --git a/src/launchpad-process-pool/loader_context.cc b/src/launchpad-process-pool/loader_context.cc index a0137f98..f8263f8b 100644 --- a/src/launchpad-process-pool/loader_context.cc +++ b/src/launchpad-process-pool/loader_context.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2023 - 2025 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -191,6 +191,7 @@ void LoaderContext::Dispose() { _E("Dispose. type(%d), name(%s), pid(%d)", GetType(), GetLoaderName().c_str(), GetPid()); + DeleteReadyFile(); if (pid_ > 0) { _D("Kill process(%d)", pid_); if (kill(pid_, SIGKILL) != 0) @@ -640,7 +641,7 @@ void LoaderContext::CreateReadyFile() { std::string path = "/tmp/." + std::to_string(getuid()) + "-" + GetLoaderName() + ".ready"; std::filesystem::path file_path(path); - if (std::filesystem::exists(file_path)) { + if (access(file_path.c_str(), F_OK) == 0) { ready_file_created_ = true; return; } @@ -660,4 +661,27 @@ void LoaderContext::CreateReadyFile() { ready_file_created_ = true; } +void LoaderContext::DeleteReadyFile() { + if (!ready_file_created_) return; + + std::string path = + "/tmp/." + std::to_string(getuid()) + "-" + GetLoaderName() + ".ready"; + std::filesystem::path file_path(path); + if (access(file_path.c_str(), F_OK) != 0) { + ready_file_created_ = false; + return; + } + + std::error_code error; + std::filesystem::remove(file_path, error); + if (error) { + _E("Failed to remove the file. path(%s), error(%s)", + path.c_str(), error.message().c_str()); + return; + } + + _W("File(%s) deleted successfully", path.c_str()); + ready_file_created_ = false; +} + } // namespace launchpad diff --git a/src/launchpad-process-pool/loader_context.hh b/src/launchpad-process-pool/loader_context.hh index e868c810..b01c6040 100644 --- a/src/launchpad-process-pool/loader_context.hh +++ b/src/launchpad-process-pool/loader_context.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2023 - 2025 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -118,6 +118,7 @@ class LoaderContext : public std::enable_shared_from_this, void OnIOEventReceived(int fd, int condition) override; int GetSchedPriority() const; void CreateReadyFile(); + void DeleteReadyFile(); private: void UpdateScore();