mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 02:28:21 +00:00
Deprecate HOOK_BRO_OBJ_DTOR and related methods
This commit is contained in:
parent
4d4c6280e9
commit
1496b99a34
9 changed files with 112 additions and 15 deletions
|
@ -669,6 +669,11 @@ void Manager::RequestBroObjDtor(Obj* obj, Plugin* plugin)
|
|||
obj->NotifyPluginsOnDtor();
|
||||
}
|
||||
|
||||
void Manager::RequestObjDtor(Obj* obj, Plugin* plugin)
|
||||
{
|
||||
obj->NotifyPluginsOnDtor();
|
||||
}
|
||||
|
||||
int Manager::HookLoadFile(const Plugin::LoadType type, const string& file, const string& resolved)
|
||||
{
|
||||
HookArgumentList args;
|
||||
|
@ -905,6 +910,29 @@ void Manager::HookBroObjDtor(void* obj) const
|
|||
MetaHookPost(HOOK_BRO_OBJ_DTOR, args, HookArgument());
|
||||
}
|
||||
|
||||
void Manager::HookObjDtor(void* obj) const
|
||||
{
|
||||
HookArgumentList args;
|
||||
|
||||
if ( HavePluginForHook(META_HOOK_PRE) )
|
||||
{
|
||||
args.push_back(HookArgument(obj));
|
||||
MetaHookPre(HOOK_OBJ_DTOR, args);
|
||||
}
|
||||
|
||||
hook_list* l = hooks[HOOK_OBJ_DTOR];
|
||||
|
||||
if ( l )
|
||||
for ( hook_list::iterator i = l->begin(); i != l->end(); ++i )
|
||||
{
|
||||
Plugin* p = (*i).second;
|
||||
p->HookObjDtor(obj);
|
||||
}
|
||||
|
||||
if ( HavePluginForHook(META_HOOK_POST) )
|
||||
MetaHookPost(HOOK_OBJ_DTOR, args, HookArgument());
|
||||
}
|
||||
|
||||
void Manager::HookLogInit(const std::string& writer, const std::string& instantiating_filter,
|
||||
bool local, bool remote, const logging::WriterBackend::WriterInfo& info,
|
||||
int num_fields, const threading::Field* const* fields) const
|
||||
|
|
|
@ -226,7 +226,19 @@ public:
|
|||
*
|
||||
* @param plugin The plugin expressing interest.
|
||||
*/
|
||||
void RequestBroObjDtor(Obj* obj, Plugin* plugin);
|
||||
[[deprecated("Remove in v6.1. Use RequestObjDtor.")]] void RequestBroObjDtor(Obj* obj,
|
||||
Plugin* plugin);
|
||||
|
||||
/**
|
||||
* Register interest in the destruction of a Obj instance. When Zeek's
|
||||
* reference counting triggers the objects destructor to run, the \a
|
||||
* HookObjDtor will be called.
|
||||
*
|
||||
* @param handler The object being interested in.
|
||||
*
|
||||
* @param plugin The plugin expressing interest.
|
||||
*/
|
||||
void RequestObjDtor(Obj* obj, Plugin* plugin);
|
||||
|
||||
// Hook entry functions.
|
||||
|
||||
|
@ -321,10 +333,16 @@ public:
|
|||
void HookDrainEvents() const;
|
||||
|
||||
/**
|
||||
* Hook that informs plugins that an BroObj is being destroyed. Will be
|
||||
* Hook that informs plugins that an Obj is being destroyed. Will be
|
||||
* called only for objects that a plugin has expressed interest in.
|
||||
*/
|
||||
void HookBroObjDtor(void* obj) const;
|
||||
[[deprecated("Remove in v6.1. Use HookObjDtor.")]] void HookBroObjDtor(void* obj) const;
|
||||
|
||||
/**
|
||||
* Hook that informs plugins that an Obj is being destroyed. Will be
|
||||
* called only for objects that a plugin has expressed interest in.
|
||||
*/
|
||||
void HookObjDtor(void* obj) const;
|
||||
|
||||
/**
|
||||
* Hook into log initialization. This method will be called when a
|
||||
|
|
|
@ -33,6 +33,7 @@ const char* hook_name(HookType h)
|
|||
"LogWrite",
|
||||
"Reporter",
|
||||
"UnprocessedPacket",
|
||||
"ObjDtor",
|
||||
// MetaHooks
|
||||
"MetaHookPre",
|
||||
"MetaHookPost",
|
||||
|
@ -385,6 +386,11 @@ void Plugin::RequestBroObjDtor(Obj* obj)
|
|||
plugin_mgr->RequestBroObjDtor(obj, this);
|
||||
}
|
||||
|
||||
void Plugin::RequestObjDtor(Obj* obj)
|
||||
{
|
||||
plugin_mgr->RequestObjDtor(obj, this);
|
||||
}
|
||||
|
||||
int Plugin::HookLoadFile(const LoadType type, const std::string& file, const std::string& resolved)
|
||||
{
|
||||
return -1;
|
||||
|
@ -416,6 +422,8 @@ void Plugin::HookSetupAnalyzerTree(Connection* conn) { }
|
|||
|
||||
void Plugin::HookBroObjDtor(void* obj) { }
|
||||
|
||||
void Plugin::HookObjDtor(void* obj) { }
|
||||
|
||||
void Plugin::HookLogInit(const std::string& writer, const std::string& instantiating_filter,
|
||||
bool local, bool remote, const logging::WriterBackend::WriterInfo& info,
|
||||
int num_fields, const threading::Field* const* fields)
|
||||
|
|
|
@ -62,14 +62,15 @@ enum HookType
|
|||
HOOK_LOAD_FILE_EXT, //< Activates Plugin::HookLoadFileExtended().
|
||||
HOOK_CALL_FUNCTION, //< Activates Plugin::HookCallFunction().
|
||||
HOOK_QUEUE_EVENT, //< Activates Plugin::HookQueueEvent().
|
||||
HOOK_DRAIN_EVENTS, //< Activates Plugin::HookDrainEvents()
|
||||
HOOK_UPDATE_NETWORK_TIME, //< Activates Plugin::HookUpdateNetworkTime.
|
||||
HOOK_BRO_OBJ_DTOR, //< Activates Plugin::HookBroObjDtor.
|
||||
HOOK_SETUP_ANALYZER_TREE, //< Activates Plugin::HookAddToAnalyzerTree
|
||||
HOOK_LOG_INIT, //< Activates Plugin::HookLogInit
|
||||
HOOK_LOG_WRITE, //< Activates Plugin::HookLogWrite
|
||||
HOOK_REPORTER, //< Activates Plugin::HookReporter
|
||||
HOOK_UNPROCESSED_PACKET, //<Activates Plugin::HookUnprocessedPacket
|
||||
HOOK_DRAIN_EVENTS, //< Activates Plugin::HookDrainEvents().
|
||||
HOOK_UPDATE_NETWORK_TIME, //< Activates Plugin::HookUpdateNetworkTime().
|
||||
HOOK_BRO_OBJ_DTOR [[deprecated("Remove in v6.1. Use HOOK_OBJ_DTOR.")]],
|
||||
HOOK_SETUP_ANALYZER_TREE, //< Activates Plugin::HookAddToAnalyzerTree().
|
||||
HOOK_LOG_INIT, //< Activates Plugin::HookLogInit().
|
||||
HOOK_LOG_WRITE, //< Activates Plugin::HookLogWrite().
|
||||
HOOK_REPORTER, //< Activates Plugin::HookReporter().
|
||||
HOOK_UNPROCESSED_PACKET, //<Activates Plugin::HookUnprocessedPacket().
|
||||
HOOK_OBJ_DTOR, //< Activates Plugin::HookObjDtor().
|
||||
|
||||
// Meta hooks.
|
||||
META_HOOK_PRE, //< Activates Plugin::MetaHookPre().
|
||||
|
@ -822,11 +823,22 @@ protected:
|
|||
* Zeek's reference counting triggers the objects destructor to run,
|
||||
* \a HookBroObjDtor will be called.
|
||||
*
|
||||
* Note that his can get expensive if triggered for many objects.
|
||||
* Note that this can get expensive if triggered for many objects.
|
||||
*
|
||||
* @param handler The object being interested in.
|
||||
* @param obj The object being interested in.
|
||||
*/
|
||||
void RequestBroObjDtor(Obj* obj);
|
||||
[[deprecated("Remove in v6.1. Use RequestObjDtor.")]] void RequestBroObjDtor(Obj* obj);
|
||||
|
||||
/**
|
||||
* Registers interest in the destruction of a Obj instance. When
|
||||
* Zeek's reference counting triggers the objects destructor to run,
|
||||
* \a HookObjDtor will be called.
|
||||
*
|
||||
* Note that this can get expensive if triggered for many objects.
|
||||
*
|
||||
* @param obj The object being interested in.
|
||||
*/
|
||||
void RequestObjDtor(Obj* obj);
|
||||
|
||||
// Hook functions.
|
||||
|
||||
|
@ -972,7 +984,19 @@ protected:
|
|||
* object is already considered invalid and the pointer must not be
|
||||
* dereferenced.
|
||||
*/
|
||||
virtual void HookBroObjDtor(void* obj);
|
||||
[[deprecated("Remove in v6.1. Use HookObjDtor.")]] virtual void HookBroObjDtor(void* obj);
|
||||
|
||||
/**
|
||||
* Hook for destruction of objects registered with
|
||||
* RequestObjDtor(). When Zeek's reference counting triggers the
|
||||
* objects destructor to run, this method will be run. It may also
|
||||
* run for other objects that this plugin has not registered for.
|
||||
*
|
||||
* @param obj A pointer to the object being destroyed. Note that the
|
||||
* object is already considered invalid and the pointer must not be
|
||||
* dereferenced.
|
||||
*/
|
||||
virtual void HookObjDtor(void* obj);
|
||||
|
||||
/**
|
||||
* Hook into log initialization. This method will be called when a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue