Skip to content

Commit

Permalink
Local and off root config for plugins (#1716)
Browse files Browse the repository at this point in the history
* string iterator for getLibSearchPaths

* fixed stringiterator for localOffRootConfig

* whitespace stringiterator libSearchPaths

* formatting PluginServer.h

* formatting Shell.cpp

---------

Co-authored-by: Mateusz Daniluk <[email protected]>
Co-authored-by: Pierre Wielders <[email protected]>
  • Loading branch information
3 people authored Aug 9, 2024
1 parent 7944eb7 commit 56f9e4a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
20 changes: 9 additions & 11 deletions Source/Thunder/PluginServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1375,10 +1375,9 @@ namespace PluginHost {
uint32_t WakeupChildren(const Core::process_t parentPID, const uint32_t timeout);
#endif

std::vector<string> GetLibrarySearchPaths(const string& locator) const override
RPC::IStringIterator* GetLibrarySearchPaths(const string& locator) const override
{
std::vector<string> all_paths;

const std::vector<string> temp = _administrator.Configuration().LinkerPluginPaths();
string rootPath(PluginHost::Service::Configuration().SystemRootPath.Value());

Expand Down Expand Up @@ -1414,19 +1413,18 @@ namespace PluginHost {
all_paths.push_back(PluginPath() + locator);
}

return all_paths;
return (Core::ServiceType<RPC::StringIterator>::Create<RPC::IStringIterator>(all_paths));
}

Core::Library LoadLibrary(const string& name) {
uint8_t progressedState = 0;
Core::Library result;

std::vector<string> all_paths = GetLibrarySearchPaths(name);
std::vector<string>::const_iterator iter = std::begin(all_paths);

while ( (iter != std::end(all_paths)) && (progressedState <= 2) ) {
Core::File libraryToLoad(*iter);

RPC::IStringIterator* all_paths = GetLibrarySearchPaths(name);
string element;
while((all_paths->Next(element) == true) && (progressedState <= 2)) {
Core::File libraryToLoad(element);

if (libraryToLoad.Exists() == true) {
if (progressedState == 0) {
progressedState = 1;
Expand All @@ -1436,7 +1434,7 @@ namespace PluginHost {
// the dlopen has a process wide system lock, make sure that the, during open used lock of the
// ServiceAdministrator, is already taken before entering the dlopen. This can only be achieved
// by forwarding this call to the ServiceAdministrator, so please so...
Core::Library newLib = Core::ServiceAdministrator::Instance().LoadLibrary(iter->c_str());
Core::Library newLib = Core::ServiceAdministrator::Instance().LoadLibrary(element.c_str());

if (newLib.IsLoaded() == true) {
if (progressedState == 1) {
Expand All @@ -1459,8 +1457,8 @@ namespace PluginHost {
}
}
}
++iter;
}
all_paths->Release();

if (HasError() == false) {
if (progressedState == 0) {
Expand Down
7 changes: 2 additions & 5 deletions Source/plugins/IShell.h
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,8 @@ namespace PluginHost {
return (nullptr);
}

virtual RPC::IStringIterator* GetLibrarySearchPaths(const string&) const = 0;

private:
inline uint32_t EnableStoragePath(const string& storagePath, uint16_t permission, const string& user, const string& group)
{
Expand Down Expand Up @@ -445,11 +447,6 @@ namespace PluginHost {

void* Root(uint32_t& pid, const uint32_t waitTime, const string className, const uint32_t interface, const uint32_t version = ~0);

/* @stubgen:omit */
virtual std::vector<string> GetLibrarySearchPaths(const string&) const
{
return std::vector<string> {};
}
};

} // namespace PluginHost
Expand Down
12 changes: 6 additions & 6 deletions Source/plugins/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ namespace PluginHost
if (locator.empty() == true) {
result = Core::ServiceAdministrator::Instance().Instantiate(Core::Library(), className.c_str(), version, interface);
} else {
std::vector<string> all_paths = GetLibrarySearchPaths(locator);
std::vector<string>::const_iterator index = all_paths.begin();
while ((result == nullptr) && (index != all_paths.end())) {
Core::File file(index->c_str());
RPC::IStringIterator* all_paths = GetLibrarySearchPaths(locator);
string element;
while (all_paths->Next(element) == true) {
Core::File file(element.c_str());
if (file.Exists())
{
Core::Library resource(index->c_str());
Core::Library resource(element.c_str());
if (resource.IsLoaded())
result = Core::ServiceAdministrator::Instance().Instantiate(
resource,
className.c_str(),
version,
interface);
}
index++;
}
all_paths->Release();
}
} else {
ICOMLink* handler(QueryInterface<ICOMLink>());
Expand Down

0 comments on commit 56f9e4a

Please sign in to comment.