Skip to content

Commit

Permalink
Support Hibernate abort by calling wakeup
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianM27 committed Feb 26, 2024
1 parent c818db6 commit 7cdb14f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
35 changes: 32 additions & 3 deletions Source/WPEFramework/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,12 +709,22 @@ namespace PluginHost {
result = Core::ERROR_BAD_REQUEST;
}
else {
State(IShell::HIBERNATED);
#ifdef HIBERNATE_SUPPORT_ENABLED
Core::process_t parentPID = local->ParentPID();
local->Release();
Unlock();

SYSLOG(Logging::Notification, ("Hibernation of plugin [%s] process [%u]", Callsign().c_str(), parentPID));
result = HibernateProcess(timeout, parentPID, _administrator.Configuration().HibernateLocator().c_str(), _T(""), &_hibernateStorage);
if(result == HIBERNATE_ERROR_NONE)
Lock();
if (State() != IShell::HIBERNATED) {
SYSLOG(Logging::Startup, ("Hibernation aborted of plugin [%s] process [%u]", Callsign().c_str(), parentPID));
result = Core::ERROR_ABORTED;
}
Unlock();

if (result == HIBERNATE_ERROR_NONE) {
{
result = HibernateChildren(parentPID, timeout);
if(result != Core::ERROR_NONE)
Expand All @@ -724,14 +734,21 @@ namespace PluginHost {
WakeupProcess(timeout, parentPID, _administrator.Configuration().HibernateLocator().c_str(), _T(""), &_hibernateStorage);
}
}

if (result == Core::ERROR_NONE) {
SYSLOG(Logging::Startup, ("Hibernated plugin [%s]:[%s]", ClassName().c_str(), Callsign().c_str()));
}
Lock();
#else
local->Release();
result = Core::ERROR_NONE;
#endif
if (result == Core::ERROR_NONE) {
State(IShell::state::HIBERNATED);
SYSLOG(Logging::Notification, ("Hibernated plugin [%s]:[%s]", ClassName().c_str(), Callsign().c_str()));
}
local->Release();
else if (State() == IShell::state::HIBERNATED) {
State(IShell::ACTIVATED);
}
}
}
Unlock();
Expand Down Expand Up @@ -798,10 +815,22 @@ namespace PluginHost {

for (auto iter = childrenPIDs.begin(); iter != childrenPIDs.end(); ++iter) {
SYSLOG(Logging::Notification, ("Hibernation of plugin [%s] child process [%u]", Callsign().c_str(), *iter));
Lock();
if (State() != IShell::HIBERNATED) {
SYSLOG(Logging::Startup, ("Hibernation aborted of plugin [%s] child process [%u]", Callsign().c_str(), *iter));
result = Core::ERROR_ABORTED;
Unlock();
break;
}
Unlock();
result = HibernateProcess(timeout, *iter, _administrator.Configuration().HibernateLocator().c_str(), _T(""), &_hibernateStorage);
if (result == HIBERNATE_ERROR_NONE) {
// Hibernate Children of this process
result = HibernateChildren(*iter, timeout);
if (result == Core::ERROR_ABORTED) {
break;
}

if (result != HIBERNATE_ERROR_NONE) {
// revert Hibernation of parent
SYSLOG(Logging::Notification, ("Wakeup plugin [%s] process [%u] on Hibernate error [%d]", Callsign().c_str(), *iter, result));
Expand Down
1 change: 1 addition & 0 deletions Source/core/Portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,7 @@ namespace Core {
ERROR_CODE(ERROR_INTERNAL_JSONRPC, 55) \
ERROR_CODE(ERROR_PARSING_ENVELOPPE, 56) \
ERROR_CODE(ERROR_COMPOSIT_OBJECT, 57) \
ERROR_CODE(ERROR_ABORTED, 58)

#define ERROR_CODE(CODE, VALUE) CODE = VALUE,

Expand Down

0 comments on commit 7cdb14f

Please sign in to comment.