Skip to content

Commit

Permalink
Expose proxies by default (#1763)
Browse files Browse the repository at this point in the history
* expose all proxies

* formatting

* replace pushback with insert

* use .end()

* keep arrow tight

* return pod of data

* use visitor way

* remove unwanted struct

---------

Co-authored-by: Pierre Wielders <pierre@wielders.net>
  • Loading branch information
nxtum and pwielders authored Oct 1, 2024
1 parent 0bffff0 commit a015de2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 29 deletions.
28 changes: 11 additions & 17 deletions Source/Thunder/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,31 +1220,25 @@ namespace Plugin {
{
Core::hresult result = Core::ERROR_UNKNOWN_KEY;

RPC::Administrator::Proxies collection;

// Search for the Dangling proxies
if (RPC::Administrator::Instance().Allocations(linkId, collection) == true) {

using Iterator = IMetadata::Data::IProxiesIterator;

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

for (const ProxyStub::UnknownProxy* proxy : collection) {
std::vector<IMetadata::Data::Proxy> collection;
bool proxySearch = RPC::Administrator::Instance().Allocations(linkId, [&collection](const std::vector<ProxyStub::UnknownProxy*>& proxies) {
for (const auto& proxy : proxies) {
IMetadata::Data::Proxy data;
data.Count = proxy->ReferenceCount();
data.Instance = proxy->Implementation();
data.Interface = proxy->InterfaceId();
data.Count = proxy->ReferenceCount();
data.Name = proxy->Name();

elements.emplace_back(std::move(data));
}
collection.emplace_back(std::move(data));
}
});

outProxies = Core::ServiceType<RPC::IteratorType<Iterator>>::Create<Iterator>(std::move(elements));
ASSERT(outProxies != nullptr);
if (proxySearch == true) {
using Iterator = IMetadata::Data::IProxiesIterator;

outProxies = Core::ServiceType<RPC::IteratorType<Iterator>>::Create<Iterator>(std::move(collection));
ASSERT(outProxies != nullptr);
result = Core::ERROR_NONE;
}

return (result);
}

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

RPC::Administrator::Proxies proxies;

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

for (const ProxyStub::UnknownProxy* proxy : proxies) {
RPC::Administrator::Instance().Allocations(index.Current().ID.Value(), [](const std::vector<ProxyStub::UnknownProxy*>& proxies) {
for (const auto& 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());
}
printf("\n");
});
}
}
break;
Expand Down
20 changes: 13 additions & 7 deletions Source/com/Administrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,34 @@ namespace RPC {
void DelegatedReleases(const bool enabled) {
_delegatedReleases = enabled;
}
bool Allocations(const uint32_t id, Proxies& proxies) const {

template<typename ACTION>
bool Allocations(const uint32_t id, ACTION&& action) const {
bool found = false;
_adminLock.Lock();
if (id == 0) {
for (const auto& proxy : _channelProxyMap) {
action(proxy.second);
}
action(_danglingProxies);
found = true;
proxies = _danglingProxies;
}
}
else {
ChannelMap::const_iterator index(_channelProxyMap.begin());

while ((found == false) && (index != _channelProxyMap.end())) {

if (index->first != id) {
index++;
}
else {
found = true;
proxies = index->second;
action(index->second);
}
}
}
return (found);
_adminLock.Unlock();
return found;
}

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

0 comments on commit a015de2

Please sign in to comment.