From 0b00c16bef406cb031a2c29da693bbf4fe157688 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Mon, 20 Nov 2023 12:52:03 +0900 Subject: [PATCH 01/16] Release version 0.38.19 Changes: - Rollback SendStartupSignal() Change-Id: I519e95eb83dd0d85d2fdf59247ebd57bbf1605d8 Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index cd5da2b..4057c1f 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.18 +Version: 0.38.19 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 0179e22b2fab06bc9daa253c72c1c3a3426f56af Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Mon, 20 Nov 2023 17:36:26 +0900 Subject: [PATCH 02/16] Add restart loader condition When handling the RESTART_LOADER command, it is necessary to check whether the loader_context is launchable. In some cases, a problem occurred by launching a loader in a non-executable state. This patch fixes this case. Change-Id: I835799364d4dcd4e0d8c30e0d60a52f5ec08ff10 Signed-off-by: Changgyu Choi --- src/launchpad-process-pool/launchpad.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index bfbe8ad..1562f15 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -606,7 +606,7 @@ void Launchpad::HandleRestartLoaderRequest(std::shared_ptr request) { if (loader_context->RefCount() == 0) loader_context->Dispose(); - if (loader_context->GetPid() < 1) + if (loader_context->GetPid() < 1 && loader_context->IsLaunchable()) loader_context->Prepare(); _W("[PAD_CMD_RESTART_LOADER] loader_name: %s, pid: %d", -- 2.7.4 From 0ba2342c5fb819320736c45b1ffd4de605e2b3a5 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Tue, 21 Nov 2023 12:47:54 +0900 Subject: [PATCH 03/16] Release version 0.38.20 Changes: - Add restart loader condition Change-Id: Id4daf7244fe76857b60b5c76c52a8af5bb21b43b Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 4057c1f..8f00b45 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.19 +Version: 0.38.20 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From e6d5bee452cc2548fecc48dc6ddd6dc8a64a2c9e Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 29 Nov 2023 16:36:17 +0900 Subject: [PATCH 04/16] Increase cpu boosting interval Some low-end devices have a problem of delaying app execution at boot time. This patch improves this problem by increasing cpu boosting interval. Change-Id: Ic4c22e5a23c45a8fa31b61f0d2a460a4cf8f6dbf Signed-off-by: Changgyu Choi --- src/launchpad-process-pool/launchpad.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 1562f15..3195c71 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -214,7 +214,7 @@ Launchpad::Launchpad(int argc, char** argv) -1, true); } - g_timeout_add(1000, [](gpointer data) { + g_timeout_add(3000, [](gpointer data) { CPUBoostController::Clear(getpid()); return G_SOURCE_REMOVE; }, this); -- 2.7.4 From e83084d103ad229ff910f914664a4928d9def718 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 30 Nov 2023 09:11:40 +0900 Subject: [PATCH 05/16] Release version 0.38.21 Changes: - Increase cpu boosting interval Change-Id: I7aad16d41b598ae11e59a3ef9a09ee64d603097d Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 8f00b45..f16704f 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.20 +Version: 0.38.21 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From b9edbe6da444225d921e0d801b6fa32b2537a97c Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 13 Dec 2023 10:10:53 +0900 Subject: [PATCH 06/16] Revert "Increase cpu boosting interval" This reverts commit e6d5bee452cc2548fecc48dc6ddd6dc8a64a2c9e. Change-Id: Ifb5a779f45e05ed0b78de47efd9fcb2e3daa7b79 --- src/launchpad-process-pool/launchpad.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 3195c71..1562f15 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -214,7 +214,7 @@ Launchpad::Launchpad(int argc, char** argv) -1, true); } - g_timeout_add(3000, [](gpointer data) { + g_timeout_add(1000, [](gpointer data) { CPUBoostController::Clear(getpid()); return G_SOURCE_REMOVE; }, this); -- 2.7.4 From 742a523eb9647b051a7e0f6512733840dde8e8b8 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 13 Dec 2023 10:36:00 +0900 Subject: [PATCH 07/16] Release version 0.38.22 Changes: - Revert "Increase cpu boosting interval" Change-Id: Ie1393f64a97b77babbdca5755cc75aeaf18acdf9 Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index f16704f..b29e638 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.21 +Version: 0.38.22 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 82ef5e16b3dc0e30588bc73e4caef81fcb7aa5ff Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 15 Dec 2023 12:34:17 +0900 Subject: [PATCH 08/16] Use access() instead of std::filesystem::exists The std::filesystem::exists uses stat() internally. The read permission is needed to use stat(). It can cause the smack issues. This patch changes the implementation to using access() with F_OK option. Change-Id: I367487b010c7abf50015004e86c3bb6ad88aa0e6 Signed-off-by: Hwankyu Jhun --- src/lib/launchpad-glib/util.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/launchpad-glib/util.cc b/src/lib/launchpad-glib/util.cc index c330f5d..2e79382 100644 --- a/src/lib/launchpad-glib/util.cc +++ b/src/lib/launchpad-glib/util.cc @@ -519,11 +519,11 @@ int Util::PrepareAppSocket() { try { std::string path = "/run/aul/apps/" + std::to_string(getuid()) + "/" + std::to_string(getpid()); - ServerSocket socket; - if (!fs::exists(path)) + if (access(path.c_str(), F_OK) != 0) fs::create_directory(path); path += "/.app-sock"; + ServerSocket socket; socket.Bind(path); socket.Listen(128); socket.SetReceiveBufferSize(Socket::kSocketMaxBufferSize); -- 2.7.4 From e1d0df1f61b42727339cdba6eba37ffeb4a8be00 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 15 Dec 2023 13:28:00 +0900 Subject: [PATCH 09/16] Release version 0.38.23 Changes: - Use access() instead of std::filesystem::exists Change-Id: I4c3090d72ccb6b4d62888d9c462bd9d565cbd97e Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index b29e638..d17932d 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.22 +Version: 0.38.23 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From c7b2118b1d44cf41fd6babd3620e1b85c01ac72f Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 20 Dec 2023 10:27:20 +0900 Subject: [PATCH 10/16] Except file descriptors from closing list There is a smack issue by closing fds in the process-pool. In launchpad-process-pool, when using dlog, create a file descriptor with vlog_init(). - When creating a process-pool, close all file descriptors except for the dlog fd (at this time, the vlog fd is closed). - When using the security-manager, attempt to output dlog. Attempt to write using the vlog fd by calling vlog_write(), but at this time, actually use the fd created by the security-manager. - This fd points to /sys/fs/smackfs. - SMACK error occurred. Change-Id: I50b3f4860454f002dd550311bf48e7ef5a2916dc Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/process_pool.cc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/launchpad-process-pool/process_pool.cc b/src/launchpad-process-pool/process_pool.cc index d91bc58..82456cc 100644 --- a/src/launchpad-process-pool/process_pool.cc +++ b/src/launchpad-process-pool/process_pool.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -40,7 +41,24 @@ namespace { constexpr const char kProcessPool[] = "process-pool"; -std::vector GetDlogFds() { +bool IsExceptable(const std::string& path) { + static char buf[PATH_MAX]; + ssize_t len = readlink(path.c_str(), buf, sizeof(buf)); + if (len < 0) { + _E("readlink() is failed. errno: %d", errno); + return false; + } + + buf[len] = '\0'; + if (strstr(buf, "log") != nullptr || + strstr(buf, "trace") != nullptr || + strstr(buf, "dev") != nullptr) + return true; + + return false; +} + +std::vector GetExceptableFds() { std::vector fds; try { fs::path proc_path("/proc/self/fd"); @@ -49,7 +67,7 @@ std::vector GetDlogFds() { continue; int fd = std::stoi(entry.path().filename().string()); - if (dlog_is_log_fd(fd)) + if (dlog_is_log_fd(fd) || IsExceptable(entry.path().string())) fds.push_back(fd); } } catch (const fs::filesystem_error& e) { @@ -136,7 +154,7 @@ void ProcessPool::OnExecution() { snprintf(args[0], length, "/usr/bin/%s <%s>", kProcessPool, name_.c_str()); close(pipe_fd_[1]); - std::vector except_fds = GetDlogFds(); + std::vector except_fds = GetExceptableFds(); except_fds.push_back(pipe_fd_[0]); Util::CloseAllFds(except_fds); int ret = WaitForRequest(std::make_unique(pipe_fd_[0])); -- 2.7.4 From 4673d94e6c14bcefe819be579d7ac8a9f3098df4 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 20 Dec 2023 11:23:18 +0900 Subject: [PATCH 11/16] Handle SIGCHLD event for process-pool If the process pool is terminated, the launchpad should remove the process information. And, if sending the request to the process pool is failed, the launchpad must create a new process to execute an application. Change-Id: I1d5096394593fe3db92fbd125f468bd9b73c498f Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/app_executor.cc | 8 ++++++- src/launchpad-process-pool/app_executor.hh | 1 + src/launchpad-process-pool/launchpad.cc | 1 + src/launchpad-process-pool/loader_executor.cc | 8 ++++++- src/launchpad-process-pool/loader_executor.hh | 3 +++ src/launchpad-process-pool/loader_manager.cc | 1 + src/launchpad-process-pool/process_pool.cc | 30 ++++++++++++++++++++------- src/launchpad-process-pool/process_pool.hh | 4 ++-- 8 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/launchpad-process-pool/app_executor.cc b/src/launchpad-process-pool/app_executor.cc index 06dda58..afb2e94 100644 --- a/src/launchpad-process-pool/app_executor.cc +++ b/src/launchpad-process-pool/app_executor.cc @@ -99,7 +99,9 @@ pid_t AppExecutor::Execute(const AppInfo* app_info) { if (process_pool_->IsPrepared()) { tizen_base::Parcel parcel; parcel.WriteParcelable(*app_info); - return process_pool_->Execute(parcel); + pid_t pid = process_pool_->Execute(parcel); + if (pid > 0) + return pid; } app_info_ = app_info; @@ -111,6 +113,10 @@ void AppExecutor::DisposeCandidateProcess() { process_pool_->SetTimer(); } +void AppExecutor::HandleSigchld(pid_t pid) { + process_pool_->HandleSigchld(pid); +} + void AppExecutor::OnExecution() { UserTracer::Print(std::to_string(getpid()) + "|after calling fork(). " + app_info_->GetAppId()); diff --git a/src/launchpad-process-pool/app_executor.hh b/src/launchpad-process-pool/app_executor.hh index 94b23fa..7fd168e 100644 --- a/src/launchpad-process-pool/app_executor.hh +++ b/src/launchpad-process-pool/app_executor.hh @@ -40,6 +40,7 @@ class AppExecutor : public Executor::Delegator, pid_t Execute(const AppInfo* app_info); void DisposeCandidateProcess(); + void HandleSigchld(pid_t pid); private: void OnExecution() override; diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 1562f15..c12f04a 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -687,6 +687,7 @@ void Launchpad::OnSigchldReceived(pid_t pid) { launchpad::Log::Print("[SIGCHLD]", "pid(%7d)", pid); LoaderManager::GetInst().HandleSigchld(pid); + app_executor_->HandleSigchld(pid); } void Launchpad::OnLoaderPrepared(LoaderContext* loader_context) { diff --git a/src/launchpad-process-pool/loader_executor.cc b/src/launchpad-process-pool/loader_executor.cc index be307ec..1a23a67 100644 --- a/src/launchpad-process-pool/loader_executor.cc +++ b/src/launchpad-process-pool/loader_executor.cc @@ -70,7 +70,9 @@ pid_t LoaderExecutor::Execute(const LoaderContext* loader_context, b.Add("LOADER_ARGS", loader_argv_); b.Add("LOADER_PRIORITY", std::to_string(priority)); auto parcel = CreateParcelFromBundle(&b); - return process_pool_->Execute(parcel); + pid_t pid = process_pool_->Execute(parcel); + if (pid > 0) + return pid; } return Executor::Execute(priority); @@ -85,6 +87,10 @@ void LoaderExecutor::DisposeCandidateProcess() { process_pool_->SetTimer(); } +void LoaderExecutor::HandleSigchld(pid_t pid) { + process_pool_->HandleSigchld(pid); +} + void LoaderExecutor::OnExecution() { std::vector loader_argv(loader_argv_.size() + 1); int loader_argc = loader_argv_.size(); diff --git a/src/launchpad-process-pool/loader_executor.hh b/src/launchpad-process-pool/loader_executor.hh index 110ffef..9a7c708 100644 --- a/src/launchpad-process-pool/loader_executor.hh +++ b/src/launchpad-process-pool/loader_executor.hh @@ -17,6 +17,8 @@ #ifndef LAUNCHPAD_PROCESS_POOL_LOADER_EXECUTOR_HH_ #define LAUNCHPAD_PROCESS_POOL_LOADER_EXECUTOR_HH_ +#include + #include #include #include @@ -41,6 +43,7 @@ class LoaderExecutor : public Executor::Delegator, pid_t Execute(const LoaderContext* loader_context, int priority); bool HasCandidateProcess() const; void DisposeCandidateProcess(); + void HandleSigchld(pid_t pid); private: LoaderExecutor(); diff --git a/src/launchpad-process-pool/loader_manager.cc b/src/launchpad-process-pool/loader_manager.cc index 4ddee1c..472d556 100644 --- a/src/launchpad-process-pool/loader_manager.cc +++ b/src/launchpad-process-pool/loader_manager.cc @@ -93,6 +93,7 @@ void LoaderManager::HandleSigchld(pid_t pid) { } RemoveLoaderContextsByCallerPid(pid); + LoaderExecutor::GetInst().HandleSigchld(pid); } void LoaderManager::AddDefaultLoaderContexts() { diff --git a/src/launchpad-process-pool/process_pool.cc b/src/launchpad-process-pool/process_pool.cc index 82456cc..81a5c05 100644 --- a/src/launchpad-process-pool/process_pool.cc +++ b/src/launchpad-process-pool/process_pool.cc @@ -102,22 +102,38 @@ pid_t ProcessPool::Execute(const tizen_base::Parcel& parcel) { return -1; auto process = std::move(queue_.front()); - queue_.pop(); - process->Send(parcel); + queue_.erase(queue_.begin()); + if (process->Send(parcel) < 0) + return -1; + return process->GetPid(); } void ProcessPool::Dispose() { - while (!queue_.empty()) { - auto process = std::move(queue_.front()); - queue_.pop(); + for (auto& process : queue_) { process->Kill(); _D("Kill process(%d)", process->GetPid()); } - + queue_.clear(); UnsetTimer(); } +void ProcessPool::HandleSigchld(pid_t pid) { + auto iter = queue_.begin(); + while (iter != queue_.end()) { + if ((*iter)->GetPid() == pid) { + iter = queue_.erase(iter); + break; + } + + iter++; + } + + int current_process_count = static_cast(queue_.size()); + if (current_process_count != num_processes_) + SetTimer(); +} + ProcessPool::Process::Process(pid_t pid, int fd) : pid_(pid), socket_(new Socket(fd)) { } @@ -186,7 +202,7 @@ void ProcessPool::PrepareProcess() { } close(pipe_fd_[0]); - queue_.push(std::make_shared(pid, pipe_fd_[1])); + queue_.push_back(std::make_shared(pid, pipe_fd_[1])); } } diff --git a/src/launchpad-process-pool/process_pool.hh b/src/launchpad-process-pool/process_pool.hh index d38e327..7d159c2 100644 --- a/src/launchpad-process-pool/process_pool.hh +++ b/src/launchpad-process-pool/process_pool.hh @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -48,6 +47,7 @@ class ProcessPool : public Executor::Delegator, bool IsPrepared() const; pid_t Execute(const tizen_base::Parcel& parcel); void Dispose(); + void HandleSigchld(pid_t pid); void SetTimer(); private: @@ -75,7 +75,7 @@ class ProcessPool : public Executor::Delegator, int num_processes_; IEvent* event_listener_; int pipe_fd_[2] = { -1, -1 }; - std::queue> queue_; + std::vector> queue_; guint timer_ = 0; }; -- 2.7.4 From 4ba729ec4d5fa1abcd1245fd85ea9d48fd9be8d0 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 20 Dec 2023 12:43:30 +0900 Subject: [PATCH 12/16] Release version 0.38.24 Changes: - Except file descriptors from closing list - Handle SIGCHLD event for process-pool Change-Id: I7fa11a06f4c2cc08c928d78d6b56f41209c2783e Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index d17932d..89e5561 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.23 +Version: 0.38.24 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 7b4b1efecc25dbdc4f7556ce449b1b5b94670413 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 21 Dec 2023 10:15:51 +0900 Subject: [PATCH 13/16] Fix build fail issue for gcc13 Change-Id: If85456e7b588255c95b0d3315859bef0be9b1487 Signed-off-by: Changgyu Choi --- src/lib/launchpad-common/cpu_boost_controller.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/launchpad-common/cpu_boost_controller.cc b/src/lib/launchpad-common/cpu_boost_controller.cc index 615adbd..bfe0671 100644 --- a/src/lib/launchpad-common/cpu_boost_controller.cc +++ b/src/lib/launchpad-common/cpu_boost_controller.cc @@ -18,6 +18,7 @@ #include +#include #include #include "launchpad-common/log_private.hh" -- 2.7.4 From b4ab36e5f4cdff07d75413931fce7d7146928e8e Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 21 Dec 2023 11:22:48 +0900 Subject: [PATCH 14/16] Release version 0.38.25 Changes: - Fix build fail issue for gcc13 Change-Id: Iab3fbd4642e46425840d94cc8620a919136cd05e Signed-off-by: Changgyu Choi --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 89e5561..94f1e11 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.24 +Version: 0.38.25 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 41344b6e4db97bc71863012457347ca3069d637e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 2 Jan 2024 17:08:52 +0900 Subject: [PATCH 15/16] Register application info when ping delivered If the application is executed using fast launch option of the app_launcher tool, there is a timing issue. When the app process is slow to enter the main function, amd does not know the process existence. To prevent the timing issue, launchpad sends the launches process list to amd when ping request is received. Change-Id: If7dea099493e0442b2a09137467238682c63d66e Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/launchpad.cc | 28 ++++++++++++++++++++++++++++ src/launchpad-process-pool/launchpad.hh | 2 ++ src/lib/launchpad-common/types.hh | 9 +++++++++ src/lib/launchpad-glib/app_info.cc | 22 ++++++++++++++++++++-- src/lib/launchpad-glib/app_info.hh | 9 +++++++-- src/lib/launchpad-glib/util.cc | 28 +++++++++++++++++++++++----- src/lib/launchpad-glib/util.hh | 2 ++ 7 files changed, 91 insertions(+), 9 deletions(-) diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index c12f04a..8b82267 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -364,6 +364,19 @@ void Launchpad::HandleDemandRequest(std::shared_ptr request) { void Launchpad::HandlePingRequest(std::shared_ptr request) { request->SendResult(getpid()); + ping_received_ = true; + for (auto& iter : fast_launches_) { + pid_t pid = iter.first; + auto& appid = iter.second; + tizen_base::Bundle b = { + { kAulAppId, appid }, + { kAulPid, std::to_string(pid) } + }; + + Util::SendCmdToAmd(AmdCmd::AppRegisterPid, b.GetHandle(), + static_cast(AmdSocketOption::NoReply | AmdSocketOption::Bundle)); + } + fast_launches_.clear(); _W("[PAD_CMD_PING]"); } @@ -559,6 +572,20 @@ void Launchpad::LaunchRequestComplete(std::shared_ptr request) { pid_map_[request->GetPid()] = app_info->GetAppId(); launchpad::Log::Print("[LAUNCH]", "pid(%7d) | appid(%s)", request->GetPid(), app_info->GetAppId().c_str()); + if (app_info->IsFastLaunch()) { + if (ping_received_) { + tizen_base::Bundle b = { + { kAulAppId, app_info->GetAppId() }, + { kAulPid, std::to_string(request->GetPid()) } + }; + + Util::SendCmdToAmd(AmdCmd::AppRegisterPid, b.GetHandle(), + static_cast( + AmdSocketOption::NoReply | AmdSocketOption::Bundle)); + } else { + fast_launches_[request->GetPid()] = app_info->GetAppId(); + } + } } } @@ -662,6 +689,7 @@ void Launchpad::OnIOEventReceived(int fd, int condition) { } void Launchpad::OnSigchldReceived(pid_t pid) { + fast_launches_.erase(pid); auto found = pid_map_.find(pid); if (found != pid_map_.end()) { auto appid = found->second; diff --git a/src/launchpad-process-pool/launchpad.hh b/src/launchpad-process-pool/launchpad.hh index 4e6cb01..40d20ae 100644 --- a/src/launchpad-process-pool/launchpad.hh +++ b/src/launchpad-process-pool/launchpad.hh @@ -107,6 +107,8 @@ class Launchpad : public IOChannel::IEvent, std::unique_ptr cleaner_; std::vector> pending_requests_; Config::LaunchMode::Mode mode_; + bool ping_received_ = false; + std::unordered_map fast_launches_; }; } // namespace launchpad diff --git a/src/lib/launchpad-common/types.hh b/src/lib/launchpad-common/types.hh index 5b7eada..c65e1cc 100644 --- a/src/lib/launchpad-common/types.hh +++ b/src/lib/launchpad-common/types.hh @@ -69,11 +69,20 @@ enum PadLoaderId { }; enum AmdCmd { + AppRegisterPid = 57, LaunchpadDeadSignal = 61, LaunchpadLaunchSignal = 83, AppStartupSignal = 89, }; +enum class AmdSocketOption : int { + None = 0x0, + NoReply = 0x1, + Async = 0x2, + Queue = 0x4, + Bundle = 0x8 +}; + } // namespace launchpad #endif // LIB_LAUNCHPAD_COMMON_TYPES_HH_ diff --git a/src/lib/launchpad-glib/app_info.cc b/src/lib/launchpad-glib/app_info.cc index c286f6b..7e95f69 100644 --- a/src/lib/launchpad-glib/app_info.cc +++ b/src/lib/launchpad-glib/app_info.cc @@ -86,6 +86,15 @@ AppInfo::Builder& AppInfo::Builder::SetLoaderName(const tizen_base::Bundle& b) { return *this; } +AppInfo::Builder& AppInfo::Builder::SetFastLaunch(const tizen_base::Bundle& b) { + if (b.GetString(kAulFastLaunch) == "true") + fast_launch_ = true; + else + fast_launch_ = false; + + return *this; +} + AppInfo::Builder& AppInfo::Builder::SetGlobal(const tizen_base::Bundle& b) { if (b.GetString(kAulIsGlobal) == "true") global_ = true; @@ -105,7 +114,7 @@ AppInfo::Builder::operator AppInfo*() { std::move(original_app_path_), std::move(pkg_type_), std::move(app_type_), std::move(hwacc_), std::move(taskmanage_), std::move(pkg_id_), std::move(comp_type_), std::move(internal_pool_), std::move(root_path_), - std::move(loader_name_), global_, std::move(b_)); + std::move(loader_name_), fast_launch_, global_, std::move(b_)); } AppInfo* AppInfo::Create(tizen_base::Bundle b) { @@ -121,6 +130,7 @@ AppInfo* AppInfo::Create(tizen_base::Bundle b) { .SetInternalPool(b) .SetRootPath(b) .SetLoaderName(b) + .SetFastLaunch(b) .SetGlobal(b) .SetBundle(std::move(b)); } @@ -173,6 +183,10 @@ const std::string& AppInfo::GetLoaderName() const { return loader_name_; } +const bool AppInfo::IsFastLaunch() const { + return fast_launch_; +} + const bool AppInfo::IsGlobal() const { return global_; } @@ -194,6 +208,7 @@ void AppInfo::WriteToParcel(tizen_base::Parcel* parcel) const { parcel->WriteString(internal_pool_); parcel->WriteString(root_path_); parcel->WriteString(loader_name_); + parcel->WriteBool(fast_launch_); parcel->WriteBool(global_); bundle_raw* b_raw = nullptr; @@ -217,6 +232,7 @@ void AppInfo::ReadFromParcel(tizen_base::Parcel* parcel) { internal_pool_ = parcel->ReadString(); root_path_ = parcel->ReadString(); loader_name_ = parcel->ReadString(); + parcel->ReadBool(&fast_launch_); parcel->ReadBool(&global_); auto raw = parcel->ReadString(); @@ -228,7 +244,8 @@ AppInfo::AppInfo(std::string app_id, std::string app_path, std::string original_app_path, std::string pkg_type, std::string app_type, std::string hwacc, std::string taskmanage, std::string pkg_id, std::string comp_type, std::string internal_pool, std::string root_path, - std::string loader_name, bool global, tizen_base::Bundle b) + std::string loader_name, bool fast_launch, bool global, + tizen_base::Bundle b) : app_id_(std::move(app_id)), app_path_(std::move(app_path)), original_app_path_(std::move(original_app_path)), @@ -241,6 +258,7 @@ AppInfo::AppInfo(std::string app_id, std::string app_path, internal_pool_(std::move(internal_pool)), root_path_(std::move(root_path)), loader_name_(std::move(loader_name)), + fast_launch_(fast_launch), global_(global), b_(std::move(b)) {} diff --git a/src/lib/launchpad-glib/app_info.hh b/src/lib/launchpad-glib/app_info.hh index a76a862..bfafe73 100644 --- a/src/lib/launchpad-glib/app_info.hh +++ b/src/lib/launchpad-glib/app_info.hh @@ -46,6 +46,7 @@ class EXPORT_API AppInfo : public tizen_base::Parcelable { Builder& SetInternalPool(const tizen_base::Bundle& b); Builder& SetRootPath(const tizen_base::Bundle& b); Builder& SetLoaderName(const tizen_base::Bundle& b); + Builder& SetFastLaunch(const tizen_base::Bundle& b); Builder& SetGlobal(const tizen_base::Bundle& b); Builder& SetBundle(tizen_base::Bundle b); operator AppInfo*(); @@ -63,7 +64,8 @@ class EXPORT_API AppInfo : public tizen_base::Parcelable { std::string internal_pool_; std::string root_path_; std::string loader_name_; - bool global_; + bool fast_launch_ = false; + bool global_ = true; tizen_base::Bundle b_; }; @@ -84,6 +86,7 @@ class EXPORT_API AppInfo : public tizen_base::Parcelable { const std::string& GetInternalPool() const; const std::string& GetRootPath() const; const std::string& GetLoaderName() const; + const bool IsFastLaunch() const; const bool IsGlobal() const; const tizen_base::Bundle& GetBundle() const; @@ -95,7 +98,8 @@ class EXPORT_API AppInfo : public tizen_base::Parcelable { std::string original_app_path, std::string pkg_type, std::string app_type, std::string hwacc, std::string taskmanage, std::string pkg_id, std::string comp_type, std::string internal_pool, std::string root_path, - std::string loader_name, bool global, tizen_base::Bundle b); + std::string loader_name, bool fast_launch, bool global, + tizen_base::Bundle b); private: std::string app_id_; @@ -110,6 +114,7 @@ class EXPORT_API AppInfo : public tizen_base::Parcelable { std::string internal_pool_; std::string root_path_; std::string loader_name_; + bool fast_launch_ = false; bool global_ = true; tizen_base::Bundle b_; }; diff --git a/src/lib/launchpad-glib/util.cc b/src/lib/launchpad-glib/util.cc index 2e79382..e13ff46 100644 --- a/src/lib/launchpad-glib/util.cc +++ b/src/lib/launchpad-glib/util.cc @@ -16,6 +16,7 @@ #include "launchpad-glib/util.hh" +#include #include #include #include @@ -316,12 +317,23 @@ class ExternalPackage : public DBus { class AmdPacket : public tizen_base::Parcelable { public: - explicit AmdPacket(int cmd) : cmd_(cmd) {} + explicit AmdPacket(int cmd, bundle* request, int opt) + : cmd_(cmd), request_(request), opt_(opt) {} void WriteToParcel(tizen_base::Parcel* parcel) const { parcel->WriteInt32(cmd_); - parcel->WriteInt32(0); - parcel->WriteInt32(0); + if (request_ == nullptr) { + parcel->WriteInt32(0); + parcel->WriteInt32(opt_); + } else { + bundle_raw* raw = nullptr; + int len = 0; + bundle_encode(request_, &raw, &len); + parcel->WriteInt32(len); + parcel->WriteInt32(opt_); + parcel->Write(reinterpret_cast(raw), len); + bundle_free_encoded_rawdata(&raw); + } } void ReadFromParcel(tizen_base::Parcel* parcel) { @@ -329,7 +341,9 @@ class AmdPacket : public tizen_base::Parcelable { } private: - int cmd_; + int cmd_ = -1; + bundle* request_ = nullptr; + int opt_ = 0; }; } // namespace @@ -548,6 +562,10 @@ int Util::PrepareAppIdFile(const AppInfo* app_info) { } int Util::SendCmdToAmd(enum AmdCmd cmd) { + return SendCmdToAmd(cmd, nullptr, static_cast(AmdSocketOption::None)); +} + +int Util::SendCmdToAmd(enum AmdCmd cmd, bundle* request, int opt) { try { std::string endpoint = "/run/aul/daemons/.amd-sock"; ClientSocket socket; @@ -555,7 +573,7 @@ int Util::SendCmdToAmd(enum AmdCmd cmd) { socket.SetReceiveBufferSize(Socket::kSocketMaxBufferSize); socket.SetReceiveTimeout(5000); - AmdPacket packet(static_cast(cmd)); + AmdPacket packet(static_cast(cmd), request, opt); tizen_base::Parcel parcel; parcel.WriteParcelable(packet); diff --git a/src/lib/launchpad-glib/util.hh b/src/lib/launchpad-glib/util.hh index 013581c..07713ac 100644 --- a/src/lib/launchpad-glib/util.hh +++ b/src/lib/launchpad-glib/util.hh @@ -17,6 +17,7 @@ #ifndef LIB_LAUNCHPAD_GLIB_UTIL_HH_ #define LIB_LAUNCHPAD_GLIB_UTIL_HH_ +#include #include #include @@ -46,6 +47,7 @@ class EXPORT_API Util { static int PrepareAppSocket(); static int PrepareAppIdFile(const AppInfo* app_info); static int SendCmdToAmd(enum AmdCmd cmd); + static int SendCmdToAmd(enum AmdCmd cmd, bundle* request, int opt); }; } // namespace launchpad -- 2.7.4 From 478fb2dadec7fa08b778f07bcc1d0fffa8fd1343 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 2 Jan 2024 19:22:56 +0900 Subject: [PATCH 16/16] Release version 0.38.26 Changes: - Register application info when ping delivered Change-Id: I35a390f1a43b48c8f678dfc3d7d52f25174933e5 Signed-off-by: Hwankyu Jhun --- packaging/launchpad.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/launchpad.spec b/packaging/launchpad.spec index 94f1e11..5b2514a 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.38.25 +Version: 0.38.26 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4