Skip to content

Commit

Permalink
return pod of data
Browse files Browse the repository at this point in the history
  • Loading branch information
nxtum committed Sep 26, 2024
1 parent b4d7d02 commit 8e7d041
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 37 deletions.
13 changes: 6 additions & 7 deletions Source/Thunder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ namespace Plugin {
{
Core::hresult result = Core::ERROR_UNKNOWN_KEY;

RPC::Administrator::Proxies collection;
RPC::Administrator::ProxyDataVector collection;

// Search for the Dangling proxies
if (RPC::Administrator::Instance().Allocations(linkId, collection) == true) {
Expand All @@ -1229,13 +1229,12 @@ namespace Plugin {

std::list< IMetadata::Data::Proxy> elements;

for (const ProxyStub::UnknownProxy* proxy : collection) {
for (const auto &proxy : collection) {
IMetadata::Data::Proxy data;
data.Instance = proxy->Implementation();
data.Interface = proxy->InterfaceId();
data.Count = proxy->ReferenceCount();
data.Name = proxy->Name();

data.Instance = proxy.Instance;
data.Interface = proxy.Interface;
data.Count = proxy.Count;
data.Name = proxy.Name;
elements.emplace_back(std::move(data));
}

Expand Down
8 changes: 4 additions & 4 deletions Source/Thunder/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,13 +712,13 @@ POP_WARNING()
printf("Link: %s\n", index.Current().Remote.Value().c_str());
printf("------------------------------------------------------------\n");

RPC::Administrator::Proxies proxies;
RPC::Administrator::ProxyDataVector proxies;

RPC::Administrator::Instance().Allocations(index.Current().ID.Value(), proxies);

for (const ProxyStub::UnknownProxy* proxy : proxies) {
Core::instance_id instanceId = proxy->Implementation();
printf("[%s] InstanceId: 0x%" PRIx64 ", RefCount: %d, InterfaceId %d [0x%X]\n", proxy->Name().c_str(), static_cast<uint64_t>(instanceId), proxy->ReferenceCount(), proxy->InterfaceId(), proxy->InterfaceId());
for (const auto &proxy: proxies) {
Core::instance_id instanceId = proxy.Instance;
printf("[%s] InstanceId: 0x%" PRIx64 ", RefCount: %d, InterfaceId %d [0x%X]\n", proxy.Name.c_str(), static_cast<uint64_t>(instanceId), proxy.Count, proxy.Interface, proxy.Interface);
}
printf("\n");
}
Expand Down
50 changes: 50 additions & 0 deletions Source/com/Administrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,56 @@ namespace RPC {
return (systemAdministrator);
}

bool Administrator::Allocations(const uint32_t id, ProxyDataVector& proxies) const {
bool found = false;

if (id == 0) {
ChannelMap::const_iterator index(_channelProxyMap.begin());
while (index != _channelProxyMap.end() && (found == false)) {
const auto &temp = index->second;
for (const auto &proxy : temp) {
ProxyData UnknownProxyData;
UnknownProxyData.Name = proxy->Name();
UnknownProxyData.Instance = proxy->Implementation();
UnknownProxyData.Interface = proxy->InterfaceId();
UnknownProxyData.Count = proxy->ReferenceCount();
proxies.push_back(UnknownProxyData);
}
index++;
}
for (const auto& proxy: _danglingProxies) {
ProxyData UnknownProxyData;
UnknownProxyData.Name = proxy->Name();
UnknownProxyData.Instance = proxy->Implementation();
UnknownProxyData.Interface = proxy->InterfaceId();
UnknownProxyData.Count = proxy->ReferenceCount();
proxies.push_back(UnknownProxyData);
}
found = true;
}
else {
ChannelMap::const_iterator index(_channelProxyMap.begin());
while ((found == false) && (index != _channelProxyMap.end())) {
if (index->first != id) {
index++;
}
else {
found = true;
const auto &temp = index->second;
for (const auto &proxy : temp) {
ProxyData UnknownProxyData;
UnknownProxyData.Name = proxy->Name();
UnknownProxyData.Instance = proxy->Implementation();
UnknownProxyData.Interface = proxy->InterfaceId();
UnknownProxyData.Count = proxy->ReferenceCount();
proxies.push_back(UnknownProxyData);
}
}
}
}
return (found);
}

void Administrator::AddRef(const Core::ProxyType<Core::IPCChannel>& channel, void* impl, const uint32_t interfaceId)
{
// stub are loaded before any action is taken and destructed if the process closes down, so no need to lock..
Expand Down
36 changes: 10 additions & 26 deletions Source/com/Administrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,15 @@ namespace RPC {
};

public:
struct ProxyData {
uint32_t Interface;
string Name;
Core::instance_id Instance;
uint32_t Count;
};

using Proxies = std::vector<ProxyStub::UnknownProxy*>;
using ProxyDataVector = std::vector<ProxyData>;
using ChannelMap = std::unordered_map<uint32_t, Proxies>;
using ReferenceMap = std::unordered_map<uint32_t, std::list< RecoverySet > >;
using Stubs = std::unordered_map<uint32_t, ProxyStub::UnknownStub*>;
Expand All @@ -147,32 +155,8 @@ namespace RPC {
void DelegatedReleases(const bool enabled) {
_delegatedReleases = enabled;
}
bool Allocations(const uint32_t id, Proxies& proxies) const {
bool found = false;
if (id == 0) {
ChannelMap::const_iterator index(_channelProxyMap.begin());
while (index != _channelProxyMap.end()) {
const auto &temp = index->second;
proxies.insert(proxies.end(), temp.begin(), temp.end());
index++;
}
proxies.insert(proxies.end(), _danglingProxies.begin(), _danglingProxies.end());
found = true;
}
else {
ChannelMap::const_iterator index(_channelProxyMap.begin());
while ((found == false) && (index != _channelProxyMap.end())) {
if (index->first != id) {
index++;
}
else {
found = true;
proxies = index->second;
}
}
}
return (found);
}

bool Allocations(const uint32_t id, ProxyDataVector& proxies) const;

template <typename ACTUALINTERFACE, typename PROXY, typename STUB>
void Announce()
Expand Down

0 comments on commit 8e7d041

Please sign in to comment.