mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Avoid searching a directory for dynamic plugins multiple times
This commit is contained in:
parent
f2d3bf3037
commit
36099c5553
2 changed files with 20 additions and 0 deletions
|
@ -7,6 +7,8 @@
|
|||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <limits.h> // for PATH_MAX
|
||||
#include <cstdlib>
|
||||
#include <optional>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
@ -70,6 +72,19 @@ void Manager::SearchDynamicPlugins(const std::string& dir)
|
|||
return;
|
||||
}
|
||||
|
||||
char canon_path[PATH_MAX];
|
||||
if ( ! realpath(dir.data(), canon_path) )
|
||||
{
|
||||
DBG_LOG(DBG_PLUGINS, "skip dynamic plugin search in %s, realpath failed: %s",
|
||||
dir.data(), strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
if ( searched_dirs.count(canon_path) )
|
||||
return;
|
||||
|
||||
searched_dirs.emplace(canon_path);
|
||||
|
||||
// Check if it's a plugin dirctory.
|
||||
|
||||
const std::string magic = dir + "/__bro_plugin__";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue