From 96c4e450dadad97403a53878676151fe2ec5be06 Mon Sep 17 00:00:00 2001 From: Hwankyu Jhun Date: Mon, 24 Jul 2023 16:01:57 +0900 Subject: [PATCH] Modify SIGCHLD handler If SIGCHLD signal is received, launchpad checks whether the pending request exists or not. If it exists, launchpad sends the launch signal to listeners. Change-Id: Ie82b4df2b49ce02beb95a4b7547584b6a674d424 Signed-off-by: Hwankyu Jhun --- src/launchpad-process-pool/dbus.cc | 2 +- src/launchpad-process-pool/launchpad.cc | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/launchpad-process-pool/dbus.cc b/src/launchpad-process-pool/dbus.cc index 36b02b9..da24593 100644 --- a/src/launchpad-process-pool/dbus.cc +++ b/src/launchpad-process-pool/dbus.cc @@ -165,7 +165,7 @@ class DBusManager { return; } - _D("[DBUS] %s", args->GetLogMessage().c_str()); + _W("[DBUS] %s", args->GetLogMessage().c_str()); } void WorkerThread() { diff --git a/src/launchpad-process-pool/launchpad.cc b/src/launchpad-process-pool/launchpad.cc index 1891bf5..1ffb1ec 100644 --- a/src/launchpad-process-pool/launchpad.cc +++ b/src/launchpad-process-pool/launchpad.cc @@ -598,6 +598,22 @@ void Launchpad::OnSigchldReceived(pid_t pid) { pid_map_.erase(found); } + auto iter = pending_requests_.begin(); + while (iter != pending_requests_.end()) { + auto request = *iter; + auto context = request->GetAvailableLoaderContext(); + if (context != nullptr && context->GetPid() == pid) { + context->Unref(); + auto* app_info = request->GetAppInfo(); + launchpad::DBus::SendAppLaunchSignal(context->GetPid(), + app_info->GetAppId().c_str()); + pending_requests_.erase(iter); + break; + } + + iter++; + } + launchpad::Log::Print("[SIGCHLD]", "pid(%7d)", pid); LoaderManager::GetInst().HandleSigchld(pid); } -- 2.7.4