EventMgr: Add Dispatch() with handler and args

Allow users to call event_mgr.Dispatch(handler, args) instead of
constructing the Event instance themselves. Deprecate the old API
and replace users.

There's a subtle change that net_done() may be propagated via
auto_publish() now, but that still needs opt-in from script land
and likely no one did that, or else they'd expected to have it
work anyhow.
This commit is contained in:
Arne Welzel 2025-04-07 09:53:44 +02:00
parent 6d97d5526a
commit 0e027fa4e3
7 changed files with 34 additions and 14 deletions

View file

@ -106,6 +106,22 @@ void EventMgr::Dispatch(Event* event, bool no_remote) {
Unref(event);
}
void EventMgr::Dispatch(const EventHandlerPtr& h, zeek::Args vl) {
auto* ev = new Event(h, std::move(vl));
// Technically this isn't queued, but still give plugins a chance to
// intercept the event and cancel or modify it if really wanted.
bool done = PLUGIN_HOOK_WITH_RESULT(HOOK_QUEUE_EVENT, HookQueueEvent(ev), false);
if ( done )
return;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
// TODO: Open-code the old Dispatch() implementation here in v8.1.
Dispatch(ev);
#pragma GCC diagnostic pop
}
void EventMgr::Drain() {
if ( event_queue_flush_point )
Enqueue(event_queue_flush_point, Args{});