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
Commits
13d83395
Commit
13d83395
authored
3 years ago
by
Jason Hiser
Browse files
Options
Downloads
Patches
Plain Diff
Prevent duplicate loading of plugins if they are in the path twice.
parent
177363ad
No related branches found
Branches containing commit
No related tags found
Loading
Pipeline
#13550
failed
3 years ago
Stage: clean
Stage: build
Stage: test
Changes
1
Pipelines
1
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
+
22
−
0
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.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment