From c7b0045b49fa404eae846a665f0050c85204ad55 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 17 Aug 2023 10:30:31 +0900 Subject: [PATCH 01/16] Release version 0.36.4 Changes: - Modify CPUBoostingController Change-Id: I744cdf875f803142a9bfb9115625008fa3deed53 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 4b9695a..75e4d3a 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.36.3 +Version: 0.36.4 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 78f5909518b8e89f5a45e68d0e482352ac503289 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 7 Aug 2023 09:16:41 +0900 Subject: [PATCH 02/16] Create ready files of loader process A new function is added to create a ready file of the loader. The function creates the file that the path is "/run/user//..ready". Change-Id: Id2c6181793650c55b866deddbf2c68ff3b43f1d6 Signed-off-by: Hwankyu Jhun --- src/app-defined-loader/app-defined-loader.cc | 6 +++++ src/launchpad-loader/launchpad_loader.cc | 5 ++++ src/launchpad-process-pool/loader_info.cc | 3 +++ src/lib/launchpad/inc/launchpad.h | 14 +++++++++-- src/lib/launchpad/launchpad_loader.cc | 37 +++++++++++++++++++++++++++- src/lib/launchpad/launchpad_loader.hh | 2 ++ 6 files changed, 64 insertions(+), 3 deletions(-) diff --git a/src/app-defined-loader/app-defined-loader.cc b/src/app-defined-loader/app-defined-loader.cc index 57e7ffd..5c8ebef 100644 --- a/src/app-defined-loader/app-defined-loader.cc +++ b/src/app-defined-loader/app-defined-loader.cc @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -156,6 +157,11 @@ class AppDefinedLoader { _E("Plugin::PrepareApp() is failed. error(%d)", ret); _exit(EXIT_FAILURE); } + + g_idle_add([](gpointer data) { + launchpad_loader_create_ready_file(); + return G_SOURCE_REMOVE; + }, nullptr); } static int OnLaunch(int argc, char** argv, const char* app_path, diff --git a/src/launchpad-loader/launchpad_loader.cc b/src/launchpad-loader/launchpad_loader.cc index cc62aa1..2cae7ac 100644 --- a/src/launchpad-loader/launchpad_loader.cc +++ b/src/launchpad-loader/launchpad_loader.cc @@ -17,6 +17,7 @@ #include "launchpad-loader/launchpad_loader.hh" #include +#include #include #include @@ -174,6 +175,10 @@ void LaunchpadLoader::OnCreate(const tizen_base::Bundle& extra, int type) { InitializeElementary(); hw_acc_config_.reset(new launchpad::HWAccelerationConfig()); + g_idle_add([](gpointer user_data) { + launchpad_loader_create_ready_file(); + return G_SOURCE_REMOVE; + }, nullptr); } int LaunchpadLoader::OnLaunch(const LaunchArgs& args) { diff --git a/src/launchpad-process-pool/loader_info.cc b/src/launchpad-process-pool/loader_info.cc index df00c5c..4640a0d 100644 --- a/src/launchpad-process-pool/loader_info.cc +++ b/src/launchpad-process-pool/loader_info.cc @@ -27,6 +27,8 @@ #include #include +#include + #include "launchpad-process-pool/log_private.hh" #include "launchpad-process-pool/util.hh" @@ -278,6 +280,7 @@ LoaderInfo::LoaderInfo(LoaderType type, std::string name, std::string exe, on_boot_timeout_(on_boot_timeout), sched_priority_(sched_priority), condition_path_exists_(std::move(condition_path_exists)) { + extra_.Add(kAulLoaderName, name_); } LoaderType LoaderInfo::GetType() const { diff --git a/src/lib/launchpad/inc/launchpad.h b/src/lib/launchpad/inc/launchpad.h index b7d6c21..d95d624 100644 --- a/src/lib/launchpad/inc/launchpad.h +++ b/src/lib/launchpad/inc/launchpad.h @@ -85,7 +85,7 @@ bundle *launchpad_loader_get_bundle(void); * @brief Blocks all sub threads of the loader. * @remarks This function has to be called in the main thread. * - * @return @c on success, + * @return @c 0 on success, * otherwise a negative error value * * @see #launchpad_loader_unblock_threads() @@ -96,12 +96,22 @@ int launchpad_loader_block_threads(void); * @brief Unblocks all sub threads of the loader. * @remarks This function has to be called in the main thread. * - * @return @c on success, + * @return @c 0 on success, * otherwise a negative error value * @see #launchpad_loader_block_threads() */ int launchpad_loader_unblock_threads(void); +/** + * @brief Creates a ready file. + * @details This function creates a ready file. + * The path of the ready file is "/run/user//..ready". + * + * @return @c 0 on success, + * otherwise a negative error value + */ +int launchpad_loader_create_ready_file(void); + #ifdef __cplusplus } #endif diff --git a/src/lib/launchpad/launchpad_loader.cc b/src/lib/launchpad/launchpad_loader.cc index e7d733c..f967ea6 100644 --- a/src/lib/launchpad/launchpad_loader.cc +++ b/src/lib/launchpad/launchpad_loader.cc @@ -22,16 +22,20 @@ #include #include +#include +#include +#include #include #include +#include #include #include #include #include #include -#include #include +#include #include "launchpad/log_private.hh" #include "launchpad/step_prepare_execution.hh" @@ -122,6 +126,10 @@ const tizen_base::Bundle& LaunchpadLoader::GetBundle() const { return app_info_.GetBundle(); } +const std::string& LaunchpadLoader::GetLoaderName() const { + return loader_name_; +} + void LaunchpadLoader::ResetArgs() { memset(argv_[LoaderArg::Type], 0, strlen(argv_[LoaderArg::Type])); memset(argv_[LoaderArg::Id], 0, strlen(argv_[LoaderArg::Id])); @@ -185,6 +193,10 @@ bool LaunchpadLoader::OnCreate() { threads = std::stoi(threads_str); } + loader_name_ = extra.GetString(kAulLoaderName); + if (!loader_name_.empty()) + _W("name: %s", loader_name_.c_str()); + callback_.create(extra.GetHandle(), loader_type_, user_data_); aul_launch_worker_init(); WaitForThreads(threads); @@ -384,3 +396,26 @@ extern "C" EXPORT_API int launchpad_loader_block_threads(void) { extern "C" EXPORT_API int launchpad_loader_unblock_threads(void) { return ThreadControl::GetInst().UnblockThreads(); } + +extern "C" EXPORT_API int launchpad_loader_create_ready_file(void) { + if (!::context) + return -1; + + std::string path = "/run/user/" + std::to_string(getuid()) + "/." + + ::context->GetLoaderName() + ".ready"; + std::filesystem::path file_path(path); + if (std::filesystem::exists(file_path)) { + _D("Already exists. path(%s)", path.c_str()); + return 0; + } + + std::ofstream file_stream(file_path); + if (!file_stream.is_open()) { + _E("Failed to create the file. path(%s)", path.c_str()); + return -1; + } + + file_stream.close(); + _W("File(%s) created successfully", path.c_str()); + return 0; +} diff --git a/src/lib/launchpad/launchpad_loader.hh b/src/lib/launchpad/launchpad_loader.hh index 8f44252..4277d3a 100644 --- a/src/lib/launchpad/launchpad_loader.hh +++ b/src/lib/launchpad/launchpad_loader.hh @@ -41,6 +41,7 @@ class LaunchpadLoader { void* user_data); void Quit(); const tizen_base::Bundle& GetBundle() const; + const std::string& GetLoaderName() const; private: void WaitForThreads(int threads); @@ -68,6 +69,7 @@ class LaunchpadLoader { char** argv_; int loader_type_; int loader_id_; + std::string loader_name_; loader_lifecycle_callback_s callback_ = { nullptr, }; loader_adapter_s adapter_callback_ = { nullptr, }; void* user_data_ = nullptr; -- 2.7.4 From d32f825ecbd2ecce91756cca648f659a07a1371e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 17 Aug 2023 12:56:53 +0900 Subject: [PATCH 03/16] Create ready file for all loaders When the loader process is connecting to the launchpad-process-pool, the launchpad-process-pool creates a ready file to notify that the loader is ready. Change-Id: Iff44684329682d56782c1b3ffeb9cff1e9425d1e Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/loader_context.cc | 30 +++++++++++++++++++++++++++- src/launchpad-process-pool/loader_context.hh | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/launchpad-process-pool/loader_context.cc b/src/launchpad-process-pool/loader_context.cc index 53e8ab1..b47e57d 100644 --- a/src/launchpad-process-pool/loader_context.cc +++ b/src/launchpad-process-pool/loader_context.cc @@ -21,9 +21,14 @@ #include #include #include +#include #include #include +#include +#include +#include +#include #include #include @@ -632,8 +637,10 @@ void LoaderContext::HandleLoaderEvent() { SetPid(peer_cred->GetPid()); prepared_ = true; - if (listener_ != nullptr) + if (listener_ != nullptr) { + CreateReadyFile(); listener_->OnLoaderPrepared(this); + } SECURE_LOGI("Type %d loader was connected. pid: %d", GetType(), pid_); UserTracer::Print("Type " + std::to_string(GetType()) + @@ -666,4 +673,25 @@ void LoaderContext::OnIOEventReceived(int fd, int condition) { HandleLoaderClientEvent(condition); } +void LoaderContext::CreateReadyFile() { + std::string path = "/run/aul/daemons/" + std::to_string(getuid()) + "/." + + GetLoaderName() + ".ready"; + std::filesystem::path file_path(path); + if (std::filesystem::exists(file_path)) + return; + + std::ofstream file_stream(file_path); + if (!file_stream.is_open()) { + _E("Failed to create the file. path(%s)", path.c_str()); + return; + } + + file_stream.close(); + + if (smack_setlabel(path.c_str(), "*", SMACK_LABEL_ACCESS) != 0) + _E("smack_setlabel() is failed. path: %s, errno: %d", path.c_str(), errno); + + _W("File(%s) created successfully", path.c_str()); +} + } // namespace launchpad diff --git a/src/launchpad-process-pool/loader_context.hh b/src/launchpad-process-pool/loader_context.hh index 15ad2b8..1bba362 100644 --- a/src/launchpad-process-pool/loader_context.hh +++ b/src/launchpad-process-pool/loader_context.hh @@ -115,6 +115,7 @@ class LoaderContext : public std::enable_shared_from_this, void SetPrepared(bool prepared); void OnIOEventReceived(int fd, int condition) override; int GetSchedPriority() const; + void CreateReadyFile(); private: void UpdateScore(); -- 2.7.4 From 9e6ab8cda164199fa01edbd45ed7743a1445cb0b Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 17 Aug 2023 12:57:54 +0900 Subject: [PATCH 04/16] Revert "Create ready files of loader process" This reverts commit 78f5909518b8e89f5a45e68d0e482352ac503289. Change-Id: I54e852a6f3f54f2b2c207bd6ad763d60c00d48d3 --- src/app-defined-loader/app-defined-loader.cc | 6 ----- src/launchpad-loader/launchpad_loader.cc | 5 ---- src/launchpad-process-pool/loader_info.cc | 3 --- src/lib/launchpad/inc/launchpad.h | 14 ++--------- src/lib/launchpad/launchpad_loader.cc | 37 +--------------------------- src/lib/launchpad/launchpad_loader.hh | 2 -- 6 files changed, 3 insertions(+), 64 deletions(-) diff --git a/src/app-defined-loader/app-defined-loader.cc b/src/app-defined-loader/app-defined-loader.cc index 5c8ebef..57e7ffd 100644 --- a/src/app-defined-loader/app-defined-loader.cc +++ b/src/app-defined-loader/app-defined-loader.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -157,11 +156,6 @@ class AppDefinedLoader { _E("Plugin::PrepareApp() is failed. error(%d)", ret); _exit(EXIT_FAILURE); } - - g_idle_add([](gpointer data) { - launchpad_loader_create_ready_file(); - return G_SOURCE_REMOVE; - }, nullptr); } static int OnLaunch(int argc, char** argv, const char* app_path, diff --git a/src/launchpad-loader/launchpad_loader.cc b/src/launchpad-loader/launchpad_loader.cc index 2cae7ac..cc62aa1 100644 --- a/src/launchpad-loader/launchpad_loader.cc +++ b/src/launchpad-loader/launchpad_loader.cc @@ -17,7 +17,6 @@ #include "launchpad-loader/launchpad_loader.hh" #include -#include #include #include @@ -175,10 +174,6 @@ void LaunchpadLoader::OnCreate(const tizen_base::Bundle& extra, int type) { InitializeElementary(); hw_acc_config_.reset(new launchpad::HWAccelerationConfig()); - g_idle_add([](gpointer user_data) { - launchpad_loader_create_ready_file(); - return G_SOURCE_REMOVE; - }, nullptr); } int LaunchpadLoader::OnLaunch(const LaunchArgs& args) { diff --git a/src/launchpad-process-pool/loader_info.cc b/src/launchpad-process-pool/loader_info.cc index 4640a0d..df00c5c 100644 --- a/src/launchpad-process-pool/loader_info.cc +++ b/src/launchpad-process-pool/loader_info.cc @@ -27,8 +27,6 @@ #include #include -#include - #include "launchpad-process-pool/log_private.hh" #include "launchpad-process-pool/util.hh" @@ -280,7 +278,6 @@ LoaderInfo::LoaderInfo(LoaderType type, std::string name, std::string exe, on_boot_timeout_(on_boot_timeout), sched_priority_(sched_priority), condition_path_exists_(std::move(condition_path_exists)) { - extra_.Add(kAulLoaderName, name_); } LoaderType LoaderInfo::GetType() const { diff --git a/src/lib/launchpad/inc/launchpad.h b/src/lib/launchpad/inc/launchpad.h index d95d624..b7d6c21 100644 --- a/src/lib/launchpad/inc/launchpad.h +++ b/src/lib/launchpad/inc/launchpad.h @@ -85,7 +85,7 @@ bundle *launchpad_loader_get_bundle(void); * @brief Blocks all sub threads of the loader. * @remarks This function has to be called in the main thread. * - * @return @c 0 on success, + * @return @c on success, * otherwise a negative error value * * @see #launchpad_loader_unblock_threads() @@ -96,22 +96,12 @@ int launchpad_loader_block_threads(void); * @brief Unblocks all sub threads of the loader. * @remarks This function has to be called in the main thread. * - * @return @c 0 on success, + * @return @c on success, * otherwise a negative error value * @see #launchpad_loader_block_threads() */ int launchpad_loader_unblock_threads(void); -/** - * @brief Creates a ready file. - * @details This function creates a ready file. - * The path of the ready file is "/run/user//..ready". - * - * @return @c 0 on success, - * otherwise a negative error value - */ -int launchpad_loader_create_ready_file(void); - #ifdef __cplusplus } #endif diff --git a/src/lib/launchpad/launchpad_loader.cc b/src/lib/launchpad/launchpad_loader.cc index f967ea6..e7d733c 100644 --- a/src/lib/launchpad/launchpad_loader.cc +++ b/src/lib/launchpad/launchpad_loader.cc @@ -22,20 +22,16 @@ #include #include -#include -#include -#include #include #include -#include #include #include #include #include #include -#include #include +#include #include "launchpad/log_private.hh" #include "launchpad/step_prepare_execution.hh" @@ -126,10 +122,6 @@ const tizen_base::Bundle& LaunchpadLoader::GetBundle() const { return app_info_.GetBundle(); } -const std::string& LaunchpadLoader::GetLoaderName() const { - return loader_name_; -} - void LaunchpadLoader::ResetArgs() { memset(argv_[LoaderArg::Type], 0, strlen(argv_[LoaderArg::Type])); memset(argv_[LoaderArg::Id], 0, strlen(argv_[LoaderArg::Id])); @@ -193,10 +185,6 @@ bool LaunchpadLoader::OnCreate() { threads = std::stoi(threads_str); } - loader_name_ = extra.GetString(kAulLoaderName); - if (!loader_name_.empty()) - _W("name: %s", loader_name_.c_str()); - callback_.create(extra.GetHandle(), loader_type_, user_data_); aul_launch_worker_init(); WaitForThreads(threads); @@ -396,26 +384,3 @@ extern "C" EXPORT_API int launchpad_loader_block_threads(void) { extern "C" EXPORT_API int launchpad_loader_unblock_threads(void) { return ThreadControl::GetInst().UnblockThreads(); } - -extern "C" EXPORT_API int launchpad_loader_create_ready_file(void) { - if (!::context) - return -1; - - std::string path = "/run/user/" + std::to_string(getuid()) + "/." + - ::context->GetLoaderName() + ".ready"; - std::filesystem::path file_path(path); - if (std::filesystem::exists(file_path)) { - _D("Already exists. path(%s)", path.c_str()); - return 0; - } - - std::ofstream file_stream(file_path); - if (!file_stream.is_open()) { - _E("Failed to create the file. path(%s)", path.c_str()); - return -1; - } - - file_stream.close(); - _W("File(%s) created successfully", path.c_str()); - return 0; -} diff --git a/src/lib/launchpad/launchpad_loader.hh b/src/lib/launchpad/launchpad_loader.hh index 4277d3a..8f44252 100644 --- a/src/lib/launchpad/launchpad_loader.hh +++ b/src/lib/launchpad/launchpad_loader.hh @@ -41,7 +41,6 @@ class LaunchpadLoader { void* user_data); void Quit(); const tizen_base::Bundle& GetBundle() const; - const std::string& GetLoaderName() const; private: void WaitForThreads(int threads); @@ -69,7 +68,6 @@ class LaunchpadLoader { char** argv_; int loader_type_; int loader_id_; - std::string loader_name_; loader_lifecycle_callback_s callback_ = { nullptr, }; loader_adapter_s adapter_callback_ = { nullptr, }; void* user_data_ = nullptr; -- 2.7.4 From 880808289e0b699c489f4f8c1185a31ab5d8f807 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Thu, 17 Aug 2023 13:25:11 +0900 Subject: [PATCH 05/16] Release version 0.36.5 Changes: - Create ready files of loader process - Create ready file for all loaders - Revert "Create ready files of loader process" Change-Id: I142352c805c36c4a5bf212c3c8f5a80f0ef3bcbd 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 75e4d3a..2df8a0a 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.36.4 +Version: 0.36.5 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 5b68f21600680a7875232a878cc1ffaff18b114c Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 17 Aug 2023 18:10:48 +0900 Subject: [PATCH 06/16] Fix crash issue This patch is for a below crash issue. #3 0xb6d503ce in __GI_abort () at abort.c:79 #4 0xb706dc1c in __gnu_cxx::__verbose_terminate_handler () at ../../../../libstdc++-v3/libsupc++/vterminate.cc:95 #5 0xb707c336 in __cxxabiv1::__terminate ( handler=0xb707e820 <__gnu_cxx::__verbose_terminate_handler()>) at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:47 #6 0xb707c39f in std::terminate () at ../../../../libstdc++-v3/libsupc++/eh_terminate.cc:57 #7 0x800b2cba in std::thread::~thread (this=0x810b5a9c, __in_chrg=) at /usr/lib/gcc/i586-tizen-linux-gnu/9.2.0/include/c++/thread:139 #8 launchpad::Worker::~Worker (this=0x810b5a80, __in_chrg=) at /usr/src/debug/launchpad-0.36.3-1.i386/src/launchpad-process-pool/worker.cc:46 #9 0x800b2ce2 in launchpad::Worker::~Worker (this=0x810b5a80, __in_chrg=) at /usr/src/debug/launchpad-0.36.3-1.i386/src/launchpad-process-pool/worker.cc:46 #10 0x8009978c in std::default_delete::operator() ( this=0x800ccb18 , __ptr=) at /usr/lib/gcc/i586-tizen-linux-gnu/9.2.0/include/c++/bits/unique_ptr.h:75 #11 std::unique_ptr >::reset ( __p=, this=0x800ccb18 ) at /usr/lib/gcc/i586-tizen-linux-gnu/9.2.0/include/c++/bits/unique_ptr.h:394 #12 launchpad::SignalManager::Dispose ( this=this@entry=0x800cca00 ) at /usr/src/debug/launchpad-0.36.3-1.i386/src/launchpad-process-pool/signal_manager.cc:121 #13 0x8009983f in launchpad::SignalManager::Dispose ( this=0x800cca00 ) at /usr/src/debug/launchpad-0.36.3-1.i386/src/launchpad-process-pool/signal_manager.cc:171 #14 launchpad::SignalManager::~SignalManager ( this=0x800cca00 , __in_chrg=) at /usr/src/debug/launchpad-0.36.3-1.i386/src/launchpad-process-pool/signal_manager.cc:171 #15 0xb6d6bfff in __run_exit_handlers (status=status@entry=-1, listp=0xb6f0339c <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true, run_dtors=run_dtors@entry=true) at exit.c:108 #16 0xb6d6c1d5 in __GI_exit (status=-1) at exit.c:139 #17 0x80096948 in launchpad::ProcessPool::OnExecution (this=) at /usr/src/debug/launchpad-0.36.3-1.i386/src/launchpad-process-pool/process_pool.cc:118 #18 0x80071b03 in launchpad::Executor::Execute (this=this@entry=0x810b8044, priority=priority@entry=0) at /usr/src/debug/launchpad-0.36.3-1.i386/src/launchpad-process-pool/executor.cc:50 #19 0x80096b09 in launchpad::ProcessPool::PrepareProcess (this=0x810b8040) Change-Id: I96ff11d3fb0fc6d368d531e4ecc38bf10135bc84 Signed-off-by: Changgyu Choi --- src/launchpad-process-pool/dbus.cc | 2 ++ src/launchpad-process-pool/worker.cc | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/launchpad-process-pool/dbus.cc b/src/launchpad-process-pool/dbus.cc index da24593..92a2a42 100644 --- a/src/launchpad-process-pool/dbus.cc +++ b/src/launchpad-process-pool/dbus.cc @@ -105,6 +105,8 @@ class DBusManager { } delete queue_; + } else { + thread_.detach(); } disposed_ = true; diff --git a/src/launchpad-process-pool/worker.cc b/src/launchpad-process-pool/worker.cc index 0b2dd45..1a2e972 100644 --- a/src/launchpad-process-pool/worker.cc +++ b/src/launchpad-process-pool/worker.cc @@ -48,6 +48,8 @@ Worker::~Worker() { Add(std::make_shared()); thread_.join(); delete queue_; + } else { + thread_.detach(); } } -- 2.7.4 From 1943ee4296773b33f794ef13ffe108d9790da689 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Thu, 17 Aug 2023 19:26:27 +0900 Subject: [PATCH 07/16] Release version 0.36.6 Changes: - Fix crash issue Change-Id: I820f4de159dae3bccfd592bd832d2d79951d51f1 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 2df8a0a..dbca123 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.36.5 +Version: 0.36.6 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 00886c1cf25c421d2c891560600c7d9acfd52898 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Fri, 18 Aug 2023 13:56:24 +0900 Subject: [PATCH 08/16] Remove timeout setting of applying cpu boosting Unfortunately, the plugin module of the resource API does not support timeout feature properly. According to the guide, if the timeout setting exists, we must not call the resource_clear_cpu_boosting() function. This patch changes the timeout argument to -1 from the 5000 (milliseconds). Change-Id: Ice734819300b11d150231a149b6529cb92315281 Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/launchpad.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index bc51ef5..13bc490 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -196,8 +196,7 @@ Launchpad::Launchpad(int argc, char** argv) std::placeholders::_1) }, }; - CPUBoostController::DoBoost(getpid(), CPUBoostController::Level::Strong, - 5000); + CPUBoostController::DoBoost(getpid(), CPUBoostController::Level::Strong, -1); g_timeout_add(1000, [](gpointer data) { CPUBoostController::Clear(getpid()); return G_SOURCE_REMOVE; -- 2.7.4 From fc422b70c1490fb6cfc01545f3840749a4d421b5 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 21 Aug 2023 09:31:39 +0900 Subject: [PATCH 09/16] Release version 0.36.7 Changes: - Remove timeout setting of applying cpu boosting Change-Id: Ic39e5674387538b20622bba6d058840a37baabab 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 dbca123..ec21ffb 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.36.6 +Version: 0.36.7 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 1988852bce7b2ced3359a48528f319041dd4c501 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 23 Aug 2023 15:16:10 +0900 Subject: [PATCH 10/16] Add setting priority to 0 before OnAdapterLoopBegin() Change-Id: Ib72a523d8e3e2fd5700f7bbcc92e3ec2b6c3eee3 Signed-off-by: Changgyu Choi --- src/lib/launchpad/launchpad_loader.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/launchpad/launchpad_loader.cc b/src/lib/launchpad/launchpad_loader.cc index e7d733c..57816c2 100644 --- a/src/lib/launchpad/launchpad_loader.cc +++ b/src/lib/launchpad/launchpad_loader.cc @@ -36,6 +36,7 @@ #include "launchpad/log_private.hh" #include "launchpad/step_prepare_execution.hh" #include "launchpad/thread_control.hh" +#include "launchpad-common/sched_priority.hh" namespace launchpad { namespace { @@ -110,6 +111,7 @@ int LaunchpadLoader::Run(loader_lifecycle_callback_s* callback, return -1; } + SchedPriority::Set(0); OnAdapterLoopBegin(); return OnTerminate(); } -- 2.7.4 From 2023e95e8ab4f9d86211146c66fbf2cc9a838959 Mon Sep 17 00:00:00 2001 From: Changgyu Choi Date: Wed, 23 Aug 2023 15:33:13 +0900 Subject: [PATCH 11/16] Release version 0.36.8 Changes: - Add setting priority to 0 before OnAdapterLoopBegin() Change-Id: Ia254a37b83a5eb425df7e0fac98d7682f6ca99a6 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 ec21ffb..e7b21f7 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.36.7 +Version: 0.36.8 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From b44132d5569dfe5ee9de56fd54b11529be06e8dc Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 28 Aug 2023 14:42:32 +0900 Subject: [PATCH 12/16] Check CPU boosting level before calling boost API If the boosting is already applied to the launchpad-process-pool, calling the resource_set_cpu_boosting() is not needed. Change-Id: I14e564fa644e312c7eb6ca1305b222dd208ff3ca Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/launchpad.cc | 13 +++++++- src/lib/launchpad-common/cpu_boost_controller.cc | 38 ++++++++++++++++++++++++ src/lib/launchpad-common/cpu_boost_controller.hh | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 13bc490..4733c99 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -196,7 +196,18 @@ Launchpad::Launchpad(int argc, char** argv) std::placeholders::_1) }, }; - CPUBoostController::DoBoost(getpid(), CPUBoostController::Level::Strong, -1); + CPUBoostController::Level level; + int ret = CPUBoostController::GetBoostLevel(getpid(), &level); + if (ret != 0) + CPUBoostController::Clear(getpid()); + + if (ret != 0 || + level == CPUBoostController::Level::None || + level == CPUBoostController::Level::Weak) { + CPUBoostController::DoBoost(getpid(), CPUBoostController::Level::Strong, + -1); + } + g_timeout_add(1000, [](gpointer data) { CPUBoostController::Clear(getpid()); return G_SOURCE_REMOVE; diff --git a/src/lib/launchpad-common/cpu_boost_controller.cc b/src/lib/launchpad-common/cpu_boost_controller.cc index eb06ffe..c72d80b 100644 --- a/src/lib/launchpad-common/cpu_boost_controller.cc +++ b/src/lib/launchpad-common/cpu_boost_controller.cc @@ -18,6 +18,8 @@ #include +#include + #include "launchpad-common/log_private.hh" namespace launchpad { @@ -58,4 +60,40 @@ void CPUBoostController::Clear(pid_t pid) { _D("resource_clear_cpu_boosting() is successful"); } +int CPUBoostController::GetBoostLevel(pid_t pid, + CPUBoostController::Level* level) { + if (pid < 1 || level == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + resource_pid_t res_pid = { + .pid = 0, + .tid = &pid, + .tid_count = 1, + }; + cpu_boosting_level_info_t info; + _W("resource_get_cpu_boosting_level() ++"); + int ret = resource_get_cpu_boosting_level(res_pid, &info); + _W("resource_get_cpu_boosting_level() --"); + if (ret != 0) { + _E("resource_get_cpu_boosting_level() is failed. error: %d", ret); + return -1; + } + + std::unique_ptr auto_free(info.tid_level, + std::free); + + if (info.tid_level[0] == CPU_BOOSTING_LEVEL_STRONG) + *level = CPUBoostController::Level::Strong; + else if (info.tid_level[0] == CPU_BOOSTING_LEVEL_MEDIUM) + *level = CPUBoostController::Level::Medium; + else if (info.tid_level[0] == CPU_BOOSTING_LEVEL_WEAK) + *level = CPUBoostController::Level::Weak; + else + *level = CPUBoostController::Level::None; + + return 0; +} + } // namespace launchpad diff --git a/src/lib/launchpad-common/cpu_boost_controller.hh b/src/lib/launchpad-common/cpu_boost_controller.hh index 308f598..ae0df27 100644 --- a/src/lib/launchpad-common/cpu_boost_controller.hh +++ b/src/lib/launchpad-common/cpu_boost_controller.hh @@ -35,6 +35,7 @@ class EXPORT_API CPUBoostController { static void DoBoost(pid_t pid, Level level, int timeout_msec); static void Clear(pid_t pid); + static int GetBoostLevel(pid_t pid, Level* level); }; } // namespace launchpad -- 2.7.4 From 59e413be0fdbfe1387938e4d68df87084db2397e Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 28 Aug 2023 15:28:28 +0900 Subject: [PATCH 13/16] Release version 0.36.9 Changes: - Check CPU boosting level before calling boost API Change-Id: Ib8b62f651161c9d4f11c369d015a2639178cc708 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 e7b21f7..3b57eaa 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.36.8 +Version: 0.36.9 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 2dde3302007ef8fa63c754f8a86339e87884f098 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 30 Aug 2023 13:39:43 +0900 Subject: [PATCH 14/16] Handle restart request Some platform developer wants to restart the loader process directly. This patch supports the restart command. Change-Id: I003891a8a9e5160c9b43d5ca11a61f3b79742662 Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/launchpad.cc | 23 +++++++++++++++++++++++ src/launchpad-process-pool/launchpad.hh | 1 + src/lib/launchpad-common/types.hh | 1 + 3 files changed, 25 insertions(+) diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 4733c99..672bc98 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -194,6 +194,9 @@ Launchpad::Launchpad(int argc, char** argv) { PadCmd::KillLoader, std::bind(&Launchpad::HandleKillLoaderRequest, this, std::placeholders::_1) }, + { PadCmd::RestartLoader, + std::bind(&Launchpad::HandleRestartLoaderRequest, this, + std::placeholders::_1) }, }; CPUBoostController::Level level; @@ -588,6 +591,26 @@ void Launchpad::HandleKillLoaderRequest(std::shared_ptr request) { _D("[PAD_CMD_KILL_LOADER] loader_name: %s", loader_name.c_str()); } +void Launchpad::HandleRestartLoaderRequest(std::shared_ptr request) { + auto& b = request->GetBundle(); + auto loader_name = b.GetString(kAulLoaderName); + auto loader_context = + LoaderManager::GetInst().FindLoaderContextFromName(loader_name); + if (loader_context == nullptr) { + _E("Failed to find loader context. loader_name(%s)", loader_name.c_str()); + return; + } + + if (loader_context->RefCount() == 0) + loader_context->Dispose(); + + if (loader_context->GetPid() < 1) + loader_context->Prepare(); + + _D("[PAD_CMD_RESTART_LOADER] loader_name: %s, pid: %d", + loader_name.c_str(), loader_context->GetPid()); +} + void Launchpad::OnIOEventReceived(int fd, int condition) { auto client_socket = socket_->Accept(); if (!client_socket) { diff --git a/src/launchpad-process-pool/launchpad.hh b/src/launchpad-process-pool/launchpad.hh index b287375..acf7670 100644 --- a/src/launchpad-process-pool/launchpad.hh +++ b/src/launchpad-process-pool/launchpad.hh @@ -77,6 +77,7 @@ class Launchpad : public IOChannel::IEvent, void HandleConnectRequest(std::shared_ptr request); void HandleLaunchRequest(std::shared_ptr request); void HandleKillLoaderRequest(std::shared_ptr request); + void HandleRestartLoaderRequest(std::shared_ptr request); bool CanUseLoaderContext(const std::shared_ptr& context); LaunchResult ForkProcessing(std::shared_ptr request); diff --git a/src/lib/launchpad-common/types.hh b/src/lib/launchpad-common/types.hh index dca55f4..7483b36 100644 --- a/src/lib/launchpad-common/types.hh +++ b/src/lib/launchpad-common/types.hh @@ -58,6 +58,7 @@ enum PadCmd { PrepareAppDefinedLoader = 17, Connect = 18, KillLoader = 19, + RestartLoader = 20, }; enum PadLoaderId { -- 2.7.4 From 6c6353ca4d0035dcc2c2cfed17c801dee40fca7a Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Wed, 30 Aug 2023 14:52:38 +0900 Subject: [PATCH 15/16] Release version 0.37.0 Changes: - Handle restart request Change-Id: Ia6e7b0b58772a7ecbfe27100882574da17c801d7 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 3b57eaa..d01adca 100644 --- a/packaging/launchpad.spec +++ b/packaging/launchpad.spec @@ -1,6 +1,6 @@ Name: launchpad Summary: Launchpad for launching applications -Version: 0.36.9 +Version: 0.37.0 Release: 1 Group: Application Framework/Daemons License: Apache-2.0 -- 2.7.4 From 774e3f3d04db8aa4c4a9e2f6536cdbf30f2f03a9 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Tue, 29 Aug 2023 15:53:57 +0900 Subject: [PATCH 16/16] Do not close all file descriptors When the loader fails to find the main function, it tries to execute an application using execv(). Before calling execv(), the loader closes all opened file descriptors. Unfortunately, the loader can have crashed by that. To avoid crash issues, this patch removes calling CloseAllFds(). Change-Id: I902d2f73ae30dc63e4d82599da6c1ced436e3920 Signed-off-by: Hwankyu Jhun --- src/app-defined-loader/app-defined-loader.cc | 1 - src/launchpad-loader/launchpad_loader.cc | 1 - 2 files changed, 2 deletions(-) diff --git a/src/app-defined-loader/app-defined-loader.cc b/src/app-defined-loader/app-defined-loader.cc index 57e7ffd..a135dc7 100644 --- a/src/app-defined-loader/app-defined-loader.cc +++ b/src/app-defined-loader/app-defined-loader.cc @@ -183,7 +183,6 @@ class AppDefinedLoader { argv_[0], errno, strerror_r(errno, err_str, sizeof(err_str))); } else { SECURE_LOGD("[candidate] Exec application (%s)", argv_[0]); - launchpad::Util::CloseAllFds(); if (!libdir.empty()) setenv("LD_LIBRARY_PATH", libdir.c_str(), 1); unsetenv("AUL_LOADER_INIT"); diff --git a/src/launchpad-loader/launchpad_loader.cc b/src/launchpad-loader/launchpad_loader.cc index cc62aa1..83cb8e3 100644 --- a/src/launchpad-loader/launchpad_loader.cc +++ b/src/launchpad-loader/launchpad_loader.cc @@ -265,7 +265,6 @@ int LaunchpadLoader::DoExec(int argc, char** argv, const std::string& lib_dir) { SECURE_LOGE("access() is failed. path(%s), errno(%d)", argv[0], errno); SECURE_LOGD("Execute application. path(%s)", argv[0]); - Util::CloseAllFds(); if (!lib_dir.empty()) setenv("LD_LIBRARY_PATH", lib_dir.c_str(), 1); -- 2.7.4