Skip to content

Commit

Permalink
Merge branch 'master' into development/sharedbuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
msieben authored Aug 15, 2024
2 parents 635fd0a + 2a4a942 commit 0c42ff7
Show file tree
Hide file tree
Showing 40 changed files with 2,860 additions and 986 deletions.
1 change: 1 addition & 0 deletions Source/Thunder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ endif()

target_link_libraries(${TARGET}
PRIVATE
CompileSettings::CompileSettings
CompileSettingsDebug::CompileSettingsDebug
${NAMESPACE}Core::${NAMESPACE}Core
${NAMESPACE}Cryptalgo::${NAMESPACE}Cryptalgo
Expand Down
60 changes: 10 additions & 50 deletions Source/Thunder/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,46 +362,6 @@ namespace PluginHost {
Core::JSON::String PluginConfigPath;
};

#ifdef PROCESSCONTAINERS_ENABLED

class ProcessContainerConfig : public Core::JSON::Container {
public:
ProcessContainerConfig()
: Logging(_T("NONE"))
{

Add(_T("logging"), &Logging);
}
ProcessContainerConfig(const ProcessContainerConfig& copy)
: Logging(copy.Logging)
{
Add(_T("logging"), &Logging);
}
ProcessContainerConfig(ProcessContainerConfig&& move) noexcept
: Logging(std::move(move.Logging))
{
Add(_T("logging"), &Logging);
}
~ProcessContainerConfig() override = default;

ProcessContainerConfig& operator=(const ProcessContainerConfig& RHS)
{
Logging = RHS.Logging;
return (*this);
}
ProcessContainerConfig& operator=(ProcessContainerConfig&& move) noexcept
{
if (this != &move) {
Logging = std::move(move.Logging);
}
return (*this);
}

Core::JSON::String Logging;
};

#endif

#ifdef HIBERNATE_SUPPORT_ENABLED
class HibernateConfig : public Core::JSON::Container {
public:
Expand Down Expand Up @@ -572,7 +532,7 @@ namespace PluginHost {
Core::JSON::DecSInt32 Longitude;
Core::JSON::Boolean DelegatedReleases;
#ifdef PROCESSCONTAINERS_ENABLED
ProcessContainerConfig ProcessContainers;
Core::JSON::String ProcessContainers;
#endif
Core::JSON::ArrayType<Core::JSON::String> LinkerPluginPaths;
Observables Observe;
Expand Down Expand Up @@ -737,13 +697,13 @@ namespace PluginHost {
, _substituter(*this)
, _configLock()
, _delegatedReleases(true)
#ifdef PROCESSCONTAINERS_ENABLED
, _ProcessContainersLogging()
#endif
#ifdef PROCESSCONTAINERS_ENABLED
, _processContainersConfig()
#endif
, _linkerPluginPaths()
#ifdef HIBERNATE_SUPPORT_ENABLED
#ifdef HIBERNATE_SUPPORT_ENABLED
, _hibernateLocator()
#endif
#endif
{
JSONConfig config;

Expand All @@ -754,7 +714,7 @@ namespace PluginHost {
_webPrefix = '/' + _prefix;
_JSONRPCPrefix = '/' + config.JSONRPC.Value();
#ifdef PROCESSCONTAINERS_ENABLED
_ProcessContainersLogging = config.ProcessContainers.Logging.Value();
_processContainersConfig = config.ProcessContainers.Value();
#endif
#ifdef HIBERNATE_SUPPORT_ENABLED
_hibernateLocator = config.Hibernate.Locator.Value();
Expand Down Expand Up @@ -882,8 +842,8 @@ POP_WARNING()
return (_JSONRPCPrefix);
}
#ifdef PROCESSCONTAINERS_ENABLED
inline const string& ProcessContainersLogging() const {
return (_ProcessContainersLogging);
inline const string& ProcessContainersConfig() const {
return (_processContainersConfig);
}
#endif

Expand Down Expand Up @@ -1175,7 +1135,7 @@ POP_WARNING()
bool _delegatedReleases;

#ifdef PROCESSCONTAINERS_ENABLED
string _ProcessContainersLogging;
string _processContainersConfig;
#endif
std::vector<std::string> _linkerPluginPaths;
#ifdef HIBERNATE_SUPPORT_ENABLED
Expand Down
83 changes: 83 additions & 0 deletions Source/Thunder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1363,5 +1363,88 @@ namespace Plugin {
// also notify the JSON RPC listeners (if any)
Exchange::Controller::JLifeTime::Event::StateChange(*this, callsign, state, reason);
}

Core::hresult Controller::BuildInfo(IMetadata::Data::BuildInfo& buildInfo) const
{
#if defined(__WINDOWS__)
buildInfo.SystemType = IMetadata::Data::BuildInfo::SYSTEM_WINDOWS;
#elif defined(__LINUX__)
buildInfo.SystemType = IMetadata::Data::BuildInfo::SYSTEM_LINUX;
#elif defined(__APPLE__)
buildInfo.SystemType = IMetadata::Data::BuildInfo::SYSTEM_MACOS;
#else
#error No system type detected
#endif

#if defined(__DEBUG__)
#if defined(_THUNDER_DEBUG_OPTIMIZED_)
buildInfo.BuildType = IMetadata::Data::BuildInfo::DEBUG_OPTIMIZED;
#else
buildInfo.BuildType = IMetadata::Data::BuildInfo::DEBUG;
#endif
#else // !__DEBUG__
#if defined(_THUNDER_NDEBUG_DEB_INFO)
buildInfo.BuildType = IMetadata::Data::BuildInfo::RELEASE_WITH_DEBUG_INFO;
#elif defined(_THUNDER_PRODUCTION)
buildInfo.BuildType = IMetadata::Data::BuildInfo::PRODUCTION;
#else
buildInfo.BuildType = IMetadata::Data::BuildInfo::RELEASE;
#endif
#endif

#ifdef _TRACE_LEVEL
buildInfo.TraceLevel = _TRACE_LEVEL;
#endif

uint8_t extensions = 0;
#ifdef __CORE_WARNING_REPORTING__
extensions |= IMetadata::Data::BuildInfo::WARNING_REPORTING;
#endif
#ifdef __CORE_BLUETOOTH_SUPPORT__
extensions |= IMetadata::Data::BuildInfo::BLUETOOTH;
#endif
#ifdef HIBERNATE_SUPPORT_ENABLED
extensions |= IMetadata::Data::BuildInfo::HIBERNATE;
#endif
#ifdef PROCESSCONTAINERS_ENABLED
extensions |= IMetadata::Data::BuildInfo::PROCESS_CONTAINERS;
#endif

if (extensions != 0) {
buildInfo.Extensions = static_cast<IMetadata::Data::BuildInfo::extensiontype>(extensions);
}

#ifdef __CORE_MESSAGING__
buildInfo.Messaging = true;
#else
buildInfo.Messaging= false;
#endif

#ifdef __CORE_EXCEPTION_CATCHING__
buildInfo.ExceptionCatching = true;
#else
buildInfo.ExceptionCatching = false;
#endif

buildInfo.InstanceIDBits = (sizeof(Core::instance_id) * 8);

#ifdef __CORE_CRITICAL_SECTION_LOG__
buildInfo.DeadlockDetection = true;
#else
buildInfo.DeadlockDetection = false;
#endif

#ifdef __CORE_NO_WCHAR_SUPPORT__
buildInfo.WCharSupport = false;
#else
buildInfo.WCharSupport = true;
#endif

#ifdef THREADPOOL_COUNT
buildInfo.ThreadPoolCount = THREADPOOL_COUNT;
#endif

return (Core::ERROR_NONE);
}
}
}
1 change: 1 addition & 0 deletions Source/Thunder/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ namespace Plugin {
Core::hresult Threads(IMetadata::Data::IThreadsIterator*& threads) const override;
Core::hresult PendingRequests(IMetadata::Data::IPendingRequestsIterator*& requests) const override;
Core::hresult Version(IMetadata::Data::Version& version) const override;
Core::hresult BuildInfo(IMetadata::Data::BuildInfo& buildInfo) const override;

// IShells overrides
Core::hresult Register(Exchange::Controller::IShells::INotification* sink) override;
Expand Down
9 changes: 4 additions & 5 deletions Source/Thunder/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#endif

#ifdef PROCESSCONTAINERS_ENABLED
#include "../processcontainers/ProcessContainer.h"
#include "../processcontainers/processcontainers.h"
#endif

#ifdef HIBERNATE_SUPPORT_ENABLED
Expand Down Expand Up @@ -1175,11 +1175,10 @@ namespace PluginHost {
// Add the controller as a service to the services.
_controller = _services.Insert(metaDataConfig, Service::mode::CONFIGURED);

#ifdef PROCESSCONTAINERS_ENABLED
#ifdef PROCESSCONTAINERS_ENABLED
// turn on ProcessContainer logging
ProcessContainers::IContainerAdministrator& admin = ProcessContainers::IContainerAdministrator::Instance();
admin.Logging(_config.VolatilePath(), configuration.ProcessContainersLogging());
#endif
ProcessContainers::ContainerAdministrator::Instance().Initialize(_config.ProcessContainersConfig());
#endif
}
POP_WARNING()

Expand Down
8 changes: 2 additions & 6 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
#include "WarningReportingCategories.h"
#include "PostMortem.h"

#ifdef PROCESSCONTAINERS_ENABLED
#include "../processcontainers/ProcessContainer.h"
#endif

#ifndef HOSTING_COMPROCESS
#error "Please define the name of the COM process!!!"
#endif
Expand Down Expand Up @@ -4188,7 +4184,7 @@ namespace PluginHost {
}
}
}
void Send(const Core::ProxyType<Web::Response>& response) override
void Send(const Core::ProxyType<Web::Response>& response VARIABLE_IS_NOT_USED) override
{
if (_requestClose == true) {
PluginHost::Channel::Close(0);
Expand All @@ -4213,7 +4209,7 @@ namespace PluginHost {

return (result);
}
void Send(const Core::ProxyType<Core::JSON::IElement>& element) override
void Send(const Core::ProxyType<Core::JSON::IElement>& element VARIABLE_IS_NOT_USED) override
{
TRACE(SocketFlow, (element));
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Thunder/Probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ namespace Plugin {
}

// Notification of a Response send.
/* virtual */ void Probe::Listener::Send(const Core::ProxyType<Web::Response>& response)
/* virtual */ void Probe::Listener::Send(const Core::ProxyType<Web::Response>& response VARIABLE_IS_NOT_USED)
{
TRACE(Discovery, (response, _destinations.front()._destination));

Expand Down
7 changes: 4 additions & 3 deletions Source/com/Communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,14 +342,15 @@ namespace RPC {

void Communicator::ContainerProcess::Terminate() /* override */
{
ASSERT(_container != nullptr);
g_destructor.Destruct(Id(), *this);
if (_container.IsValid() == true) {
g_destructor.Destruct(Id(), *this);
}
}

void Communicator::ContainerProcess::PostMortem() /* override */
{
Core::process_t pid;
if ( (_container != nullptr) && ((pid = static_cast<Core::process_t>(_container->Pid())) != 0) ) {
if ( (_container.IsValid() == true) && ((pid = static_cast<Core::process_t>(_container->Pid())) != 0) ) {
Core::ProcessInfo process(pid);
process.Dump();
}
Expand Down
53 changes: 33 additions & 20 deletions Source/com/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@


#ifdef PROCESSCONTAINERS_ENABLED
#include <processcontainers/ProcessContainer.h>
#include <processcontainers/processcontainers.h>
#endif


Expand Down Expand Up @@ -823,16 +823,21 @@ namespace RPC {

ContainerConfig()
: Core::JSON::Container()
, ContainerType(ProcessContainers::IContainer::LXC)
#ifdef __DEBUG__
, ContainerPath()
#endif
{
Add(_T("containertype"), &ContainerType);
#ifdef __DEBUG__
Add(_T("containerpath"), &ContainerPath);
#endif
}
~ContainerConfig() = default;

public:
Core::JSON::EnumType<ProcessContainers::IContainer::containertype> ContainerType;

#ifdef __DEBUG__
Core::JSON::String ContainerPath;
#endif
Expand All @@ -850,33 +855,41 @@ namespace RPC {
: MonitorableProcess(instance.Callsign(), parent)
, _process(RemoteConnection::Id(), baseConfig, instance)
{
ProcessContainers::IContainerAdministrator& admin = ProcessContainers::IContainerAdministrator::Instance();

std::vector<string> searchpaths(3);
searchpaths[0] = baseConfig.VolatilePath();
searchpaths[1] = baseConfig.PersistentPath();
searchpaths[2] = baseConfig.DataPath();

#ifdef __DEBUG__
ContainerConfig config;
config.FromString(instance.Configuration());

if (config.ContainerPath.IsSet() == true) {
searchpaths.emplace(searchpaths.cbegin(), config.ContainerPath.Value());
// Fetch container type
Core::OptionalType<Core::JSON::Error> error;
config.FromString(instance.Configuration(), error);

if (error.IsSet() == true) {
TRACE_L1("Invalid process container configuration");
}
else {
std::vector<string> searchPaths(3);

#endif
#ifdef __DEBUG__
if (config.ContainerPath.IsSet() == true) {
searchPaths.push_back(config.ContainerPath.Value());
}
#endif

searchPaths.push_back(baseConfig.VolatilePath());
searchPaths.push_back(baseConfig.PersistentPath());
searchPaths.push_back(baseConfig.DataPath());

Core::IteratorType<std::vector<string>, const string> searchpathsit(searchpaths);
Core::IteratorType<std::vector<string>, const string> searchPathsIt(searchPaths);

string volatilecallsignpath(baseConfig.VolatilePath() + instance.Callsign() + _T('/'));
_container = admin.Container(instance.Callsign(), searchpathsit, volatilecallsignpath, instance.Configuration());
const string volatilePath(Core::Directory::Normalize(baseConfig.VolatilePath() + instance.Callsign()));

_container = ProcessContainers::ContainerAdministrator::Instance().Container(config.ContainerType, instance.Callsign(),
searchPathsIt, volatilePath, instance.Configuration());
}
}

~ContainerProcess() override
{
if (_container != nullptr) {
_container->Release();
if (_container.IsValid() == true) {
_container.Release();
}
}

Expand All @@ -885,7 +898,7 @@ namespace RPC {
{
uint32_t result = Core::ERROR_GENERAL;

if (_container != nullptr) {
if (_container.IsValid() == true) {

// Note: replace below code with something more efficient when Iterators redesigned
Core::Process::Options::Iterator it(_process.Options());
Expand Down Expand Up @@ -954,7 +967,7 @@ namespace RPC {
END_INTERFACE_MAP

private:
ProcessContainers::IContainer* _container;
Core::ProxyType<ProcessContainers::IContainer> _container;
Process _process;
};

Expand Down
Loading

0 comments on commit 0c42ff7

Please sign in to comment.