From b94b09e993231d1c2b95c185e82f7018cba916b6 Mon Sep 17 00:00:00 2001 From: Adrian Muzyka Date: Thu, 18 Apr 2024 17:34:35 +0200 Subject: [PATCH] Hibernate Abort improvements - fixed logging and return in case of late abortion - quicker for multi process plugins --- Source/WPEFramework/PluginServer.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/Source/WPEFramework/PluginServer.cpp b/Source/WPEFramework/PluginServer.cpp index 2ed4c1403c..6ea447e2bd 100644 --- a/Source/WPEFramework/PluginServer.cpp +++ b/Source/WPEFramework/PluginServer.cpp @@ -746,7 +746,13 @@ namespace PluginHost { result = Core::ERROR_NONE; #endif if (result == Core::ERROR_NONE) { - SYSLOG(Logging::Startup, (_T("Hibernated plugin [%s]:[%s]"), ClassName().c_str(), Callsign().c_str())); + if (State() == IShell::state::HIBERNATED) { + SYSLOG(Logging::Startup, ("Hibernated plugin [%s]:[%s]", ClassName().c_str(), Callsign().c_str())); + } else { + // wakeup occured right after hibernation finished + SYSLOG(Logging::Startup, ("Hibernation aborted of plugin [%s]:[%s]", ClassName().c_str(), Callsign().c_str())); + result = Core::ERROR_ABORTED; + } } else if (State() == IShell::state::HIBERNATED) { State(IShell::ACTIVATED); @@ -864,13 +870,19 @@ namespace PluginHost { if (children.Count() > 0) { + // make sure to wakeup PIDs in opposite order to hibernation + // to quickly go over not hibernated PIDs and abort currently processed + std::list childrenBackward; while (children.Next()) { + childrenBackward.push_front(children.Current().Id()); + } + + for (auto iter = childrenBackward.begin(); iter != childrenBackward.end(); ++iter) { // Wakeup children of this process // There is no recovery path while doing Wakeup, don't care about errors - WakeupChildren(children.Current().Id(), timeout); - - TRACE(Activity, (_T("Wakeup of plugin [%s] child process [%u]"), Callsign().c_str(), children.Current().Id())); - result = WakeupProcess(timeout, children.Current().Id(), _administrator.Configuration().HibernateLocator().c_str(), _T(""), &_hibernateStorage); + WakeupChildren(*iter, timeout); + TRACE(Activity, (_T("Wakeup of plugin [%s] child process [%u]"), Callsign().c_str(), *iter)); + result = WakeupProcess(timeout, *iter, _administrator.Configuration().HibernateLocator().c_str(), _T(""), &_hibernateStorage); } }