Skip to content

Commit

Permalink
Hibernate Abort improvements
Browse files Browse the repository at this point in the history
 - fixed logging and return in case of late abortion
 - quicker for multi process plugins
  • Loading branch information
adrianM27 committed Apr 18, 2024
1 parent cf4fecb commit ad65817
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions Source/WPEFramework/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,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);
Expand Down Expand Up @@ -857,13 +863,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<ThreadId> 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);
}
}

Expand Down

0 comments on commit ad65817

Please sign in to comment.