Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
Zipr Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Open Source Software
Zipr Backend
Compare revisions
177363ad46ad91861030e0088857269ae55dcf40 to 13d83395e674c3c5f085f06235726f216ab47bb5
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
opensrc/zipr-be
Select target project
No results found
13d83395e674c3c5f085f06235726f216ab47bb5
Select Git revision
Swap
Target
opensrc/zipr-be
Select target project
No results found
177363ad46ad91861030e0088857269ae55dcf40
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
Prevent duplicate loading of plugins if they are in the path twice.
· 13d83395
Jason Hiser
authored
3 years ago
13d83395
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugin_man.cpp
+22
-0
22 additions, 0 deletions
src/plugin_man.cpp
with
22 additions
and
0 deletions
src/plugin_man.cpp
View file @
13d83395
...
@@ -212,6 +212,7 @@ void ZiprPluginManager_t::open_plugins
...
@@ -212,6 +212,7 @@ void ZiprPluginManager_t::open_plugins
)
)
{
{
const
auto
ziprPluginDirs
=
splitVar
(
getenv
(
"ZIPR_PLUGIN_PATH"
));
const
auto
ziprPluginDirs
=
splitVar
(
getenv
(
"ZIPR_PLUGIN_PATH"
));
auto
loadedBasenames
=
set
<
string
>
();
for
(
const
auto
dir
:
ziprPluginDirs
)
for
(
const
auto
dir
:
ziprPluginDirs
)
{
{
...
@@ -226,6 +227,15 @@ void ZiprPluginManager_t::open_plugins
...
@@ -226,6 +227,15 @@ void ZiprPluginManager_t::open_plugins
while
((
dirp
=
readdir
(
dp
))
!=
nullptr
)
while
((
dirp
=
readdir
(
dp
))
!=
nullptr
)
{
{
const
auto
basename
=
string
(
dirp
->
d_name
);
const
auto
basename
=
string
(
dirp
->
d_name
);
if
(
loadedBasenames
.
find
(
basename
)
!=
loadedBasenames
.
end
())
{
if
(
m_verbose
)
cout
<<
"Already loaded "
<<
basename
<<
". Skipping..."
<<
endl
;
continue
;
}
loadedBasenames
.
insert
(
basename
);
const
auto
name
=
dir
+
'/'
+
basename
;
const
auto
name
=
dir
+
'/'
+
basename
;
const
auto
zpi
=
string
(
".zpi"
);
const
auto
zpi
=
string
(
".zpi"
);
const
auto
extension
=
name
.
substr
(
name
.
size
()
-
zpi
.
length
());
const
auto
extension
=
name
.
substr
(
name
.
size
()
-
zpi
.
length
());
...
@@ -239,9 +249,21 @@ void ZiprPluginManager_t::open_plugins
...
@@ -239,9 +249,21 @@ void ZiprPluginManager_t::open_plugins
cout
<<
"File ("
<<
name
<<
") does not have proper extension, skipping."
<<
endl
;
cout
<<
"File ("
<<
name
<<
") does not have proper extension, skipping."
<<
endl
;
continue
;
// try next file
continue
;
// try next file
}
}
// test if this library is already loaded, can happen when
// an entry in ZIPR_PLUGIN_PATH is duplicated.
const
auto
isLoaded
=
dlopen
(
name
.
c_str
(),
RTLD_LAZY
|
RTLD_GLOBAL
|
RTLD_NOLOAD
)
!=
nullptr
;
if
(
isLoaded
)
{
if
(
m_verbose
)
cout
<<
"File ("
<<
name
<<
") already loaded."
<<
endl
;
continue
;
}
if
(
m_verbose
)
if
(
m_verbose
)
cout
<<
"Attempting load of file ("
<<
name
<<
")."
<<
endl
;
cout
<<
"Attempting load of file ("
<<
name
<<
")."
<<
endl
;
// actuall load
const
auto
handle
=
dlopen
(
name
.
c_str
(),
RTLD_LAZY
|
RTLD_GLOBAL
);
const
auto
handle
=
dlopen
(
name
.
c_str
(),
RTLD_LAZY
|
RTLD_GLOBAL
);
if
(
!
handle
)
if
(
!
handle
)
{
{
...
...
This diff is collapsed.
Click to expand it.