Skip to content

Commit

Permalink
Merge branch 'master' into scheduler_doc
Browse files Browse the repository at this point in the history
  • Loading branch information
pczekaj99 authored Mar 14, 2024
2 parents d065542 + 7988266 commit 2dd7a30
Show file tree
Hide file tree
Showing 25 changed files with 288 additions and 134 deletions.
1 change: 1 addition & 0 deletions Source/WPEFramework/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ get_filename_component(TARGET ${CMAKE_CURRENT_SOURCE_DIR} NAME)

set(THREADPOOL_COUNT "4" CACHE STRING "The number of threads in the thread pool")
set(ENABLE_INITSCRIPT_SUPPORT ON CACHE STRING "Enable init script(systemd/initd) install support from the thunder source tree")
set(ENABLE_TRACING_MODULES "" CACHE STRING "A space separated list of specific tracing modules to be enabled at start.")

add_executable(${TARGET}
Controller.cpp
Expand Down
14 changes: 12 additions & 2 deletions Source/WPEFramework/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ namespace PluginHost {
, ExitReasons()
, Latitude(51832547) // Divider 1.000.000
, Longitude(5674899) // Divider 1.000.000
, DelegatedReleases(true)
#ifdef PROCESSCONTAINERS_ENABLED
, ProcessContainers()
#endif
Expand Down Expand Up @@ -417,6 +418,7 @@ namespace PluginHost {
Add(_T("exitreasons"), &ExitReasons);
Add(_T("latitude"), &Latitude);
Add(_T("longitude"), &Longitude);
Add(_T("ccdr"), &DelegatedReleases); /* COMRPC channel delegated releases */
#ifdef PROCESSCONTAINERS_ENABLED
Add(_T("processcontainers"), &ProcessContainers);
#endif
Expand Down Expand Up @@ -460,6 +462,7 @@ namespace PluginHost {
Core::JSON::ArrayType<Core::JSON::EnumType<PluginHost::IShell::reason>> ExitReasons;
Core::JSON::DecSInt32 Latitude;
Core::JSON::DecSInt32 Longitude;
Core::JSON::Boolean DelegatedReleases;
#ifdef PROCESSCONTAINERS_ENABLED
ProcessContainerConfig ProcessContainers;
#endif
Expand Down Expand Up @@ -578,8 +581,8 @@ namespace PluginHost {
Config(const Config&) = delete;
Config& operator=(const Config&) = delete;

PUSH_WARNING(DISABLE_WARNING_THIS_IN_MEMBER_INITIALIZER_LIST)
Config(Core::File& file, const bool background, Core::OptionalType<Core::JSON::Error>& error)
PUSH_WARNING(DISABLE_WARNING_THIS_IN_MEMBER_INITIALIZER_LIST)
Config(Core::File& file, const bool background, Core::OptionalType<Core::JSON::Error>& error)
: _background(background)
, _prefix()
, _webPrefix()
Expand Down Expand Up @@ -620,6 +623,7 @@ PUSH_WARNING(DISABLE_WARNING_THIS_IN_MEMBER_INITIALIZER_LIST)
, _reasons()
, _substituter(*this)
, _configLock()
, _delegatedReleases(true)
#ifdef PROCESSCONTAINERS_ENABLED
, _ProcessContainersLogging()
#endif
Expand Down Expand Up @@ -669,6 +673,7 @@ PUSH_WARNING(DISABLE_WARNING_THIS_IN_MEMBER_INITIALIZER_LIST)
_inputInfo.Set(config.Input);
_processInfo.Set(config.Process);
_ethernetCard = config.EthernetCard.Value();
_delegatedReleases = config.DelegatedReleases.Value();
if( config.Latitude.IsSet() || config.Longitude.IsSet() ) {
SYSLOG(Logging::Error, (_T("Support for Latitude and Longitude moved from Thunder configuration to plugin providing ILocation support")));
}
Expand Down Expand Up @@ -870,6 +875,9 @@ POP_WARNING()
inline string EthernetCard() const {
return _ethernetCard;
}
inline bool DelegatedReleases() const {
return(_delegatedReleases);
}
inline const InputInfo& Input() const {
return(_inputInfo);
}
Expand Down Expand Up @@ -1046,6 +1054,8 @@ POP_WARNING()
std::list<PluginHost::IShell::reason> _reasons;
Substituter _substituter;
mutable Core::CriticalSection _configLock;
bool _delegatedReleases;

#ifdef PROCESSCONTAINERS_ENABLED
string _ProcessContainersLogging;
#endif
Expand Down
12 changes: 4 additions & 8 deletions Source/WPEFramework/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -707,17 +707,13 @@ namespace Plugin {
}

void Controller::Proxies(Core::JSON::ArrayType<PluginHost::Metadata::COMRPC>& response) const {
RPC::Administrator::Instance().Visit([&](const Core::IPCChannel& channel, const RPC::Administrator::Proxies& proxies)
RPC::Administrator::Instance().Visit([&](const RPC::Administrator::Proxies& proxies)
{
PluginHost::Metadata::COMRPC& entry(response.Add());
const RPC::Communicator::Client* comchannel = dynamic_cast<const RPC::Communicator::Client*>(&channel);
const Core::SocketPort* connection = proxies.front()->Socket();

if (comchannel != nullptr) {
string identifier = PluginHost::ChannelIdentifier(comchannel->Source());

if (identifier.empty() == false) {
entry.Remote = identifier;
}
if (connection != nullptr) {
entry.Remote = PluginHost::ChannelIdentifier(*connection);
}

for (const auto& proxy : proxies) {
Expand Down
29 changes: 12 additions & 17 deletions Source/WPEFramework/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,26 +700,21 @@ POP_WARNING()
switch (keyPress) {
case 'A': {
Core::JSON::ArrayType<Metadata::COMRPC> proxyChannels;
RPC::Administrator::Instance().Visit([&](const Core::IPCChannel& channel, const RPC::Administrator::Proxies& proxies) {
Metadata::COMRPC& entry(proxyChannels.Add());
const RPC::Communicator::Client* comchannel = dynamic_cast<const RPC::Communicator::Client*>(&channel);
RPC::Administrator::Instance().Visit([&](const RPC::Administrator::Proxies& proxies) {
Metadata::COMRPC& entry(proxyChannels.Add());
const Core::SocketPort* socketPort = proxies.front()->Socket();

if (comchannel != nullptr) {
string identifier = PluginHost::ChannelIdentifier(comchannel->Source());

if (identifier.empty() == false) {
entry.Remote = identifier;
}
}
if (socketPort != nullptr) {
entry.Remote = PluginHost::ChannelIdentifier(*socketPort);
}

for (const auto& proxy : proxies) {
Metadata::COMRPC::Proxy& info(entry.Proxies.Add());
info.Instance = proxy->Implementation();
info.Interface = proxy->InterfaceId();
info.Count = proxy->ReferenceCount();
}
for (const auto& proxy : proxies) {
Metadata::COMRPC::Proxy& info(entry.Proxies.Add());
info.Instance = proxy->Implementation();
info.Interface = proxy->InterfaceId();
info.Count = proxy->ReferenceCount();
}
);
});
Core::JSON::ArrayType<Metadata::COMRPC>::Iterator index(proxyChannels.Elements());

printf("COMRPC Links:\n");
Expand Down
7 changes: 7 additions & 0 deletions Source/WPEFramework/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,7 @@ namespace PluginHost {
const string& postMortemPath,
const uint8_t softKillCheckWaitTime,
const uint8_t hardKillCheckWaitTime,
const bool delegatedReleases,
const Core::ProxyType<RPC::InvokeServer>& handler)
: RPC::Communicator(node, ProxyStubPathCreator(proxyStubPath, observableProxyStubPath), Core::ProxyType<Core::IIPCServer>(handler))
, _parent(parent)
Expand All @@ -2045,6 +2046,11 @@ namespace PluginHost {
, _deadProxies()
, _job(*this)
{
// Shall we enable the non-happy day functionality to cleanup Release on behalf of unexpected
// channel closes. Only for testing Buggy plugins, turn it off (false)!
// STRONG RECOMMENDATION TO HAVE THIS ACTIVE (TRUE)!!!
RPC::Administrator::Instance().DelegatedReleases(delegatedReleases);

if (RPC::Communicator::Open(RPC::CommunicationTimeOut) != Core::ERROR_NONE) {
TRACE_L1("We can not open the RPC server. No out-of-process communication available. %d", __LINE__);
} else {
Expand Down Expand Up @@ -2583,6 +2589,7 @@ namespace PluginHost {
server._config.PostMortemPath(),
server._config.SoftKillCheckWaitTime(),
server._config.HardKillCheckWaitTime(),
server._config.DelegatedReleases(),
_engine)
, _subSystems(this)
, _authenticationHandler(nullptr)
Expand Down
16 changes: 14 additions & 2 deletions Source/WPEFramework/WPEFramework.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,20 @@ if boolean('@MESSAGING@'):
messaging.add("logging", __logging)

__tracing_settings = []
__tracing_settings.append(__fatal)
__tracing_settings.append(__tracing)

__enable_tracing_modules = "@ENABLE_TRACING_MODULES@".strip()
__modules =__enable_tracing_modules.split(' ') if __enable_tracing_modules else []

if len(__modules) > 0:
for module in __modules:
__module = {
"module" : module,
"enabled" : True
}
__tracing_settings.append(__module)
else:
__tracing_settings.append(__tracing)
__tracing_settings.append(__fatal)

__tracing = JSON()
__tracing.add("settings", __tracing_settings)
Expand Down
54 changes: 32 additions & 22 deletions Source/com/Administrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ namespace RPC {
, _proxy()
, _factory(8)
, _channelProxyMap()
, _channelReferenceMap()
, _danglingProxies()
, _delegatedReleases(true)
{
}

Expand Down Expand Up @@ -108,7 +111,7 @@ namespace RPC {

_adminLock.Lock();

ChannelMap::iterator index(_channelProxyMap.find(proxy.Channel().operator->()));
ChannelMap::iterator index(_channelProxyMap.find(proxy.LinkId()));

if (index != _channelProxyMap.end()) {
Proxies::iterator entry(index->second.begin());
Expand All @@ -121,8 +124,17 @@ namespace RPC {
if (index->second.size() == 0) {
_channelProxyMap.erase(index);
}
} else {
TRACE_L1("Could not find the Proxy entry to be unregistered in the channel list.");
else {
// If it is not found, check the dangling map
Proxies::iterator index = std::find(_danglingProxies.begin(), _danglingProxies.end(), &proxy);

if (index != _danglingProxies.end()) {
_danglingProxies.erase(index);
}
else {
TRACE_L1("Could not find the Proxy entry to be unregistered from a channel perspective.");
}
}
}
} else {
TRACE_L1("Could not find the Proxy entry to be unregistered from a channel perspective.");
Expand Down Expand Up @@ -176,7 +188,7 @@ namespace RPC {
if (result == false) {
_adminLock.Lock();

ReferenceMap::const_iterator index(_channelReferenceMap.find(channel.operator->()));
ReferenceMap::const_iterator index(_channelReferenceMap.find(channel->LinkId()));
const Core::IUnknown* unknown = Convert(reinterpret_cast<void*>(impl), id);

result = ((index != _channelReferenceMap.end()) &&
Expand All @@ -203,7 +215,7 @@ namespace RPC {

_adminLock.Lock();

ChannelMap::iterator index(_channelProxyMap.find(channel.operator->()));
ChannelMap::iterator index(_channelProxyMap.find(channel->LinkId()));

if (index != _channelProxyMap.end()) {
Proxies::iterator entry(index->second.begin());
Expand Down Expand Up @@ -233,7 +245,7 @@ namespace RPC {

_adminLock.Lock();

ChannelMap::iterator index(_channelProxyMap.find(channel.operator->()));
ChannelMap::iterator index(_channelProxyMap.find(channel->LinkId()));

if (index != _channelProxyMap.end()) {
Proxies::iterator entry(index->second.begin());
Expand Down Expand Up @@ -262,7 +274,7 @@ namespace RPC {
ASSERT(result != nullptr);

// Register it as it is remotely registered :-)
_channelProxyMap[channel.operator->()].push_back(result);
_channelProxyMap[channel->LinkId()].push_back(result);

// This will increment the reference count to 2 (one in the ChannelProxyMap and one in the QueryInterface ).
interface = result->QueryInterface(id);
Expand All @@ -284,11 +296,11 @@ namespace RPC {
if (reference != nullptr) {
_adminLock.Lock();

ReferenceMap::iterator index = _channelReferenceMap.find(channel.operator->());
ReferenceMap::iterator index = _channelReferenceMap.find(channel->LinkId());

if (index == _channelReferenceMap.end()) {
auto result = _channelReferenceMap.emplace(std::piecewise_construct,
std::forward_as_tuple(channel.operator->()),
std::forward_as_tuple(channel->LinkId()),
std::forward_as_tuple());
result.first->second.emplace_back(id, reference);
TRACE_L3("Registered interface %p(0x%08x).", reference, id);
Expand Down Expand Up @@ -345,7 +357,7 @@ namespace RPC {
{
_adminLock.Lock();

ReferenceMap::iterator remotes(_channelReferenceMap.find(channel.operator->()));
ReferenceMap::iterator remotes(_channelReferenceMap.find(channel->LinkId()));

if (remotes != _channelReferenceMap.end()) {
std::list<RecoverySet>::iterator loop(remotes->second.begin());
Expand All @@ -354,7 +366,7 @@ namespace RPC {
Core::IUnknown* iface = loop->Unknown();
ASSERT(iface != nullptr);

if ((iface != nullptr) && (loop->IsComposit() == false)) {
if ((_delegatedReleases == true) && (iface != nullptr) && (loop->IsComposit() == false)) {

uint32_t result;

Expand All @@ -370,19 +382,18 @@ namespace RPC {
_channelReferenceMap.erase(remotes);
}

ChannelMap::iterator index(_channelProxyMap.find(channel.operator->()));
ChannelMap::iterator index(_channelProxyMap.find(channel->LinkId()));

if (index != _channelProxyMap.end()) {
Proxies::iterator loop(index->second.begin());
while (loop != index->second.end()) {
// There is a small possibility that the last reference to this proxy
// interface is released in the same time before we report this interface
// to be dead. So lets keep a refernce so we can work on a real object
// still. This race condition, was observed by customer testing.
(*loop)->Invalidate();

loop++;
for (auto entry : index->second) {
entry->Invalidate();
_danglingProxies.emplace_back(entry);
}
// The _channelProxyMap does have a reference for each Proxy it
// holds, so it is safe to just move the vector from the map to
// the pendingProxies. The receiver of pendingProxies has to take
// care of releasing the last reference we, as administration layer
// hold upon this..
pendingProxies = std::move(index->second);
_channelProxyMap.erase(index);
}
Expand All @@ -392,6 +403,5 @@ namespace RPC {

/* static */ Administrator& Job::_administrator= Administrator::Instance();
/* static */ Core::ProxyPoolType<Job> Job::_factory(6);

}
} // namespace Core
Loading

0 comments on commit 2dd7a30

Please sign in to comment.