mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add methods to queue events without handler existence check
Added ConnectionEventFast() and QueueEventFast() methods to avoid redundant event handler existence checks. It's common practice for caller to already check for event handler existence before doing all the work of constructing the arguments, so it's desirable to not have to check for existence again. E.g. going through ConnectionEvent() means 3 existence checks: one you do yourself before calling it, one in ConnectionEvent(), and then another in QueueEvent(). The existence check itself can be more than a few operations sometimes as it needs to check a few flags that determine if it's enabled, has a local body, or has any remote receivers in the old comm. system or has been flagged as something to publish in the new comm. system.
This commit is contained in:
parent
8bc65f09ec
commit
b6862c5c59
72 changed files with 771 additions and 524 deletions
23
src/main.cc
23
src/main.cc
|
@ -340,7 +340,7 @@ void terminate_bro()
|
|||
|
||||
EventHandlerPtr bro_done = internal_handler("bro_done");
|
||||
if ( bro_done )
|
||||
mgr.QueueEvent(bro_done, val_list{});
|
||||
mgr.QueueEventFast(bro_done, val_list{});
|
||||
|
||||
timer_mgr->Expire();
|
||||
mgr.Drain();
|
||||
|
@ -1138,7 +1138,7 @@ int main(int argc, char** argv)
|
|||
EventHandlerPtr bro_init = internal_handler("bro_init");
|
||||
|
||||
if ( bro_init )
|
||||
mgr.QueueEvent(bro_init, val_list{});
|
||||
mgr.QueueEventFast(bro_init, val_list{});
|
||||
|
||||
EventRegistry::string_list* dead_handlers =
|
||||
event_registry->UnusedHandlers();
|
||||
|
@ -1184,16 +1184,19 @@ int main(int argc, char** argv)
|
|||
if ( override_ignore_checksums )
|
||||
ignore_checksums = 1;
|
||||
|
||||
// Queue events reporting loaded scripts.
|
||||
for ( std::list<ScannedFile>::iterator i = files_scanned.begin(); i != files_scanned.end(); i++ )
|
||||
if ( bro_script_loaded )
|
||||
{
|
||||
if ( i->skipped )
|
||||
continue;
|
||||
// Queue events reporting loaded scripts.
|
||||
for ( std::list<ScannedFile>::iterator i = files_scanned.begin(); i != files_scanned.end(); i++ )
|
||||
{
|
||||
if ( i->skipped )
|
||||
continue;
|
||||
|
||||
mgr.QueueEvent(bro_script_loaded, {
|
||||
new StringVal(i->name.c_str()),
|
||||
val_mgr->GetCount(i->include_level),
|
||||
});
|
||||
mgr.QueueEventFast(bro_script_loaded, {
|
||||
new StringVal(i->name.c_str()),
|
||||
val_mgr->GetCount(i->include_level),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
reporter->ReportViaEvents(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue