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 19, 2024
1 parent cf4fecb commit 9d6c169
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions Source/WPEFramework/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ namespace PluginHost {
Unlock();
result = Core::ERROR_ILLEGAL_STATE;
} else if (currentState == IShell::state::HIBERNATED) {
Unlock();
result = Wakeup(3000);
Unlock();
} else if ((currentState == IShell::state::DEACTIVATED) || (currentState == IShell::state::PRECONDITION)) {

// Load the interfaces, If we did not load them yet...
Expand Down Expand Up @@ -524,9 +524,7 @@ namespace PluginHost {

if(currentState == IShell::state::HIBERNATED)
{
Unlock();
uint32_t wakeupResult = Wakeup(3000);
Lock();
if(wakeupResult != Core::ERROR_NONE)
{
//Force Activated state
Expand Down Expand Up @@ -739,7 +737,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 All @@ -756,8 +760,6 @@ namespace PluginHost {
uint32_t Server::Service::Wakeup(const uint32_t timeout VARIABLE_IS_NOT_USED) {
Core::hresult result = Core::ERROR_NONE;

Lock();

IShell::state currentState(State());

if (currentState != IShell::state::HIBERNATED) {
Expand Down Expand Up @@ -791,7 +793,6 @@ namespace PluginHost {
local->Release();
}
}
Unlock();

return (result);
}
Expand Down Expand Up @@ -857,13 +858,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 9d6c169

Please sign in to comment.