Skip to content

Commit

Permalink
Merge pull request #433 from rdkcentral/development/R2/upstream-fixes
Browse files Browse the repository at this point in the history
Integration of upstream fixes
  • Loading branch information
pwielders authored Jan 18, 2021
2 parents 6b71595 + 8b51505 commit ce0d0e5
Show file tree
Hide file tree
Showing 16 changed files with 101 additions and 101 deletions.
3 changes: 2 additions & 1 deletion Source/WPEFramework/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace Plugin {
// "239.255.255.250:1900";
Core::NodeId node (config.Probe.Node.Value().c_str());

if (node.IsValid() == true) {
if (node.IsValid() == false) {
SYSLOG(Logging::Startup, (_T("Probing requested but invalid IP address [%s]"), config.Probe.Node.Value().c_str()));
}
else {
Expand Down Expand Up @@ -116,6 +116,7 @@ namespace Plugin {

if (subSystems != nullptr) {
subSystems->Unregister(&_systemInfoReport);
subSystems->Release();
}

if (_probe != nullptr) {
Expand Down
1 change: 1 addition & 0 deletions Source/WPEFramework/Controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ namespace Plugin {
} else {
subSystems->Unregister(&_systemInfoReport);
}
subSystems->Release();
}
}
inline uint32_t Stopped()
Expand Down
10 changes: 7 additions & 3 deletions Source/WPEFramework/PluginServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,14 @@ ENUM_CONVERSION_BEGIN(Core::ProcessInfo::scheduler)
{

void* result = nullptr;
if ((id == Core::IUnknown::ID) || (id == PluginHost::IShell::ID)) {
if (id == Core::IUnknown::ID) {
AddRef();
result = this;
} else {
result = static_cast<IUnknown*>(this);
} if (id == PluginHost::IShell::ID) {
AddRef();
result = static_cast<PluginHost::IShell*>(this);
}
else {

_pluginHandling.Lock();

Expand Down
4 changes: 2 additions & 2 deletions Source/WPEFramework/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ namespace PluginHost {
sink->AddRef();
_notifiers.push_back(sink);

// Tell this "new" sink all our active/inactive plugins..
// Tell this "new" sink all our actived plugins..
std::map<const string, Core::ProxyType<Service>>::iterator index(_services.begin());

// Notifty all plugins that we have sofar..
Expand All @@ -1667,7 +1667,7 @@ namespace PluginHost {

ASSERT(service.IsValid());

if (service.IsValid() == true) {
if ( (service.IsValid() == true) && (service->State() == IShell::ACTIVATED) ) {
sink->StateChange(&(service.operator*()));
}

Expand Down
12 changes: 5 additions & 7 deletions Source/com/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,16 @@
set(TARGET ${NAMESPACE}COM)

ProxyStubGenerator(NAMESPACE "WPEFramework::RPC" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/ICOM.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated")

set(PROXYSTUB_COM_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/generated/ProxyStubs_COM.cpp")

configure_file( "${CMAKE_CURRENT_LIST_DIR}/ProxyStubs.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/ProxyStubs.cpp"
@ONLY)
ProxyStubGenerator(NAMESPACE "WPEFramework::Trace" INPUT "${CMAKE_CURRENT_SOURCE_DIR}/ITrace.h" OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/generated")

add_library(${TARGET} SHARED
Administrator.cpp
Communicator.cpp
"${CMAKE_CURRENT_BINARY_DIR}/ProxyStubs.cpp"
ITracing.cpp
IUnknown.cpp
Module.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated/ProxyStubs_COM.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated/ProxyStubs_Trace.cpp
)

set(PUBLIC_HEADERS
Expand All @@ -43,6 +39,7 @@ set(PUBLIC_HEADERS
IStringIterator.h
IValueIterator.h
ICOM.h
ITrace.h
IUnknown.h
Messages.h
Module.h
Expand All @@ -60,6 +57,7 @@ target_link_libraries(${TARGET}
target_include_directories(${TARGET}
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

target_compile_definitions(${TARGET} PRIVATE COM_EXPORTS)
Expand Down
6 changes: 5 additions & 1 deletion Source/com/Communicator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ namespace RPC {
LocalClosingInfo& operator=(const LocalClosingInfo& RHS) = delete;

explicit LocalClosingInfo(const uint32_t pid)
: _process(pid)
: _process(false, pid)
{
}
~LocalClosingInfo() override = default;
Expand Down Expand Up @@ -511,5 +511,9 @@ namespace RPC {
// Set event so WaitForCompletion() can continue.
_announceEvent.SetEvent();
}

//We may eliminate the following statement when switched to C++17 compiler
constexpr uint32_t RPC::ProcessShutdown::DestructionStackSize;

}
}
1 change: 1 addition & 0 deletions Source/com/Communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "Administrator.h"
#include "IUnknown.h"
#include "ICOM.h"
#include "ITrace.h"

#ifdef PROCESSCONTAINERS_ENABLED
#include "../processcontainers/ProcessContainer.h"
Expand Down
22 changes: 3 additions & 19 deletions Source/com/ICOM.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// @stubgen:include "IRPCIterator.h"

namespace WPEFramework {
namespace RPC {
namespace RPC {

struct EXTERNAL IRemoteConnection : virtual public Core::IUnknown {
enum { ID = ID_COMCONNECTION };
Expand Down Expand Up @@ -61,23 +61,7 @@ namespace WPEFramework {
}
};

typedef IIteratorType<string, ID_STRINGITERATOR> IStringIterator;
typedef IIteratorType<uint32_t, ID_VALUEITERATOR> IValueIterator;
}

namespace Trace {

struct EXTERNAL ITraceIterator : virtual public Core::IUnknown {
enum { ID = RPC::ID_TRACEITERATOR };

virtual void Reset() = 0;
virtual bool Info(bool& enabled /* @out */, string& module /* @out */, string& category /* @out */) const = 0;
};

struct EXTERNAL ITraceController : virtual public Core::IUnknown {
enum { ID = RPC::ID_TRACECONTROLLER };

virtual void Enable(const bool enabled, const string& module, const string& category) = 0;
};
typedef IIteratorType<string, ID_STRINGITERATOR> IStringIterator;
typedef IIteratorType<uint32_t, ID_VALUEITERATOR> IValueIterator;
}
}
22 changes: 18 additions & 4 deletions Source/com/ProxyStubs.cpp → Source/com/ITrace.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
Expand All @@ -18,7 +17,22 @@
* limitations under the License.
*/

#include "IUnknown.h"
#include "Module.h"
#pragma once

#include "Ids.h"

namespace WPEFramework {
namespace Trace {
struct EXTERNAL ITraceIterator : virtual public Core::IUnknown {
enum { ID = RPC::ID_TRACEITERATOR };

virtual void Reset() = 0;
virtual bool Info(bool& enabled /* @out */, string& module /* @out */, string& category /* @out */) const = 0;
};
struct EXTERNAL ITraceController : virtual public Core::IUnknown {
enum { ID = RPC::ID_TRACECONTROLLER };

#include "generated/ProxyStubs_COM.cpp"
virtual void Enable(const bool enabled, const string& module, const string& category) = 0;
};
}
}
14 changes: 8 additions & 6 deletions Source/com/IUnknown.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ namespace ProxyStub {
if (outbound == false) {
_mode |= CACHING_RELEASE;
}
else {
// This is an additional call to an interface for which we already have a Proxy issued.
// This is triggerd by the other side, offering us an interface. So once this proxy goes
// out of scope, we also need to "release" the AddRef associated with this on the other
// side..
_remoteReferences++;
}

// This will increment the refcount of this PS, on behalf of the user.
result = _parent.QueryInterface(id);

// This is an additional call to an interface for which we already have a Proxy issued.
// This is triggerd by the other side, offering us an interface. So once this proxy goes
// out of scope, we also need to "release" the AddRef associated with this on the other
// side..
_remoteReferences++;
}
_adminLock.Unlock();

Expand Down
23 changes: 0 additions & 23 deletions Source/com/ProxyStubs.cpp.in

This file was deleted.

31 changes: 30 additions & 1 deletion Source/core/NetworkInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ namespace Core {
SocketDatagram::Open(Core::infinite);
}
~Observer() override {
Close(Core::infinite);
SocketDatagram::Close(Core::infinite);
}

public:
Expand All @@ -861,6 +861,16 @@ namespace Core {
void StateChange() override
{
}
void Open()
{
if (SocketDatagram::IsOpen() != true) {
SocketDatagram::Open(Core::infinite);
}
}
void Close()
{
SocketDatagram::Close(Core::infinite);
}

private:
Message _parser;
Expand Down Expand Up @@ -1070,6 +1080,7 @@ namespace Core {
, _networks()
, _observer(*this)
, _observers()
, _refCount(0)
{
ASSERT(IsValid());

Expand Down Expand Up @@ -1125,6 +1136,7 @@ namespace Core {
std::list<AdapterObserver::INotification*>::iterator index (std::find(_observers.begin(), _observers.end(), client));
if (index == _observers.end()) {
_observers.push_back(client);
AddRef();
}
_adminLock.Unlock();
}
Expand All @@ -1133,6 +1145,7 @@ namespace Core {
std::list<AdapterObserver::INotification*>::iterator index (std::find(_observers.begin(), _observers.end(), client));
if (index != _observers.end()) {
_observers.erase(index);
Release();
}
_adminLock.Unlock();
}
Expand All @@ -1141,6 +1154,21 @@ namespace Core {
}

private:
inline void AddRef() {
if (Core::InterlockedIncrement(_refCount) == 1) {
_observer.Open();
}
}
inline uint32_t Release() {

ASSERT(_refCount > 0);
if (Core::InterlockedDecrement(_refCount) == 0) {
_observer.Close();
}

return Core::ERROR_NONE;
}

void Add(const uint32_t id, const struct rtattr* data, const uint16_t length) {
string interfaceName;

Expand Down Expand Up @@ -1197,6 +1225,7 @@ namespace Core {
Map _networks;
Observer _observer;
std::list<AdapterObserver::INotification*> _observers;
uint32_t _refCount;
};

Network::Network(const uint32_t index, const struct rtattr* iface, const uint32_t length)
Expand Down
26 changes: 2 additions & 24 deletions Source/core/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ namespace Core {
Process(const Process&) = delete;
Process& operator=(const Process&) = delete;

Process(const bool capture)
explicit Process(const bool capture, const process_t pid = 0)
: _argc(0)
, _parameters(nullptr)
, _exitCode(static_cast<uint32_t>(~0))
#ifndef __WINDOWS__
, _stdin(capture ? -1 : 0)
, _stdout(capture ? -1 : 0)
, _stderr(capture ? -1 : 0)
, _PID(0)
, _PID(pid)
#else
, _stdin(capture ? reinterpret_cast<HANDLE>(~0) : nullptr)
, _stdout(capture ? reinterpret_cast<HANDLE>(~0) : nullptr)
Expand Down Expand Up @@ -595,28 +595,6 @@ namespace Core {
return (_exitCode);
}

/*
Process(process_t pid)
: _argc(0)
, _parameters(nullptr)
, _exitCode(static_cast<uint32_t>(~0))
#ifndef __WINDOWS__
, _stdin(0)
, _stdout(0)
, _stderr(0)
, _PID(pid)
#else
, _stdin(nullptr)
, _stdout(nullptr)
, _stderr(nullptr)
#endif
{
#ifdef __WINDOWS__
::memset(&_info, 0, sizeof(_info));
#endif
}
*/

private:
uint16_t _argc;
void* _parameters;
Expand Down
1 change: 1 addition & 0 deletions Source/plugins/VirtualInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,7 @@ namespace PluginHost
/* virtual */ IPCUserInput::~IPCUserInput()
{
ClearKeyMap();
_service.Cleanup();
}

/* virtual */ VirtualInput::Iterator IPCUserInput::Consumers() const
Expand Down
Loading

0 comments on commit ce0d0e5

Please sign in to comment.