mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/faster-plugin-search'
* origin/topic/jsiwek/faster-plugin-search: Avoid searching a directory for dynamic plugins multiple times
This commit is contained in:
commit
04f7259e97
4 changed files with 25 additions and 1 deletions
4
CHANGES
4
CHANGES
|
@ -1,4 +1,8 @@
|
||||||
|
|
||||||
|
4.1.0-dev.318 | 2021-03-10 12:05:47 -0800
|
||||||
|
|
||||||
|
* Avoid searching a directory for dynamic plugins multiple times (Jon Siwek, Corelight)
|
||||||
|
|
||||||
4.1.0-dev.316 | 2021-03-10 13:00:27 +0000
|
4.1.0-dev.316 | 2021-03-10 13:00:27 +0000
|
||||||
|
|
||||||
* Fix potential mime type detection bug in IRC/FTP file_transferred event
|
* Fix potential mime type detection bug in IRC/FTP file_transferred event
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.1.0-dev.316
|
4.1.0-dev.318
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <limits.h> // for PATH_MAX
|
||||||
|
#include <cstdlib>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
@ -70,6 +72,19 @@ void Manager::SearchDynamicPlugins(const std::string& dir)
|
||||||
return;
|
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.
|
// Check if it's a plugin dirctory.
|
||||||
|
|
||||||
const std::string magic = dir + "/__bro_plugin__";
|
const std::string magic = dir + "/__bro_plugin__";
|
||||||
|
|
|
@ -416,6 +416,11 @@ private:
|
||||||
void MetaHookPre(HookType hook, const HookArgumentList& args) const;
|
void MetaHookPre(HookType hook, const HookArgumentList& args) const;
|
||||||
void MetaHookPost(HookType hook, const HookArgumentList& args, const HookArgument& result) const;
|
void MetaHookPost(HookType hook, const HookArgumentList& args, const HookArgument& result) const;
|
||||||
|
|
||||||
|
// Directories that have already been searched for dynamic plugins.
|
||||||
|
// Used to prevent multiple searches of the same dirs (e.g. via symlinks).
|
||||||
|
// The paths stored in the set are made canonical via realpath().
|
||||||
|
std::set<std::string, std::less<>> searched_dirs;
|
||||||
|
|
||||||
// Plugins that were explicitly requested to be activated, but failed to
|
// Plugins that were explicitly requested to be activated, but failed to
|
||||||
// load at first.
|
// load at first.
|
||||||
std::set<std::string> requested_plugins;
|
std::set<std::string> requested_plugins;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue