Commit graph

71 commits

Author SHA1 Message Date
Tim Wojtulewicz
d95affde4d Remove deprecations tagged for v8.1 2025-08-12 10:19:03 -07:00
Tim Wojtulewicz
414728cc71 Switch to using c++20 constraints instead of std::enable_if 2025-07-28 13:03:25 -07:00
Tim Wojtulewicz
f8c04998af Remove using util.h in various headers in favor of util-types.h 2025-06-11 11:11:54 -07:00
Arne Welzel
7b4b1779bf Event: Use -1.0 for undefined/unset timestamps
This can happen if either there's no network timestamp associated with
an event, or there's currently no event being dispatched. Using 0.0
isn't great as it's the normal start timestamp before reading a network
packet. Using -1.0 gives the caller a chance to check and realize what's
going on.
2025-06-02 17:31:36 +02:00
Arne Welzel
bfcb68f8e7 Event: Move meta after args 2025-05-23 19:32:50 +02:00
Arne Welzel
89402fcc1b Event: Use IntrusivePtr to manage obj refcount
Fly-by cleanup.
2025-05-23 19:32:50 +02:00
Arne Welzel
75aa6588fe Event/zeek.bif: Add EventMetadata current() and current_values() accessors
...and basic smoke testing.
2025-05-23 19:32:50 +02:00
Arne Welzel
53b0f0ad64 Event: Deprecate default network timestamp metadata
This deprecates the Event constructor and the ``ts`` parameter of Enqueue()
Instead, versions are introduced that take a detail::MetadataVectorPtr which
can hold the network timestamp metadata and is meant to be allocated by the
caller instead of automatically during Enqueue() or within the Event
constructor.

This also introduces a BifConst ``EventMetadata::add_network_timestamp`` to
opt-in adding network timestamps to events globally. It's disabled by
default as there are not a lot of known use cases that need this.
2025-05-23 19:32:23 +02:00
Arne Welzel
12c523f3f7 Event: Store timestamp in metadata vector
This removes the ts attribute from Event and instead allocates a vector for
storing metadata. By default, adds the network time as a TimeVal. Later
patches will make the allocation of the vector optional by introducing a
different constructor so that users that are not interested in network
timestamp metadata do not take the allocation hit.

Moving the explicit ``ts`` out of the event is done in order to treat it
just as generic metadata, too. However, the Time() accessor is adapted to
lookup the value from the metadata vector instead.
2025-05-23 19:32:23 +02:00
Arne Welzel
fc96c81c70 EventMgr: Add CurrentEvent() accessor
Avoid proliferation of accessors on EventMgr.
2025-05-23 19:31:06 +02:00
Arne Welzel
0e027fa4e3 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.
2025-04-11 09:58:07 +02:00
Arne Welzel
2f9b1e21bd Event/EventMgr: protected to private
These classes are final, so deriving isn't possible. No reason to have
protected members.
2025-03-27 19:23:47 +01:00
Arne Welzel
7dadbb0c1d EventMgr: Do not cache current event attributes
Avoid proliferation of various members on EventMgr by storing the
pointer of the current event instead.

This subtly changes the behavior of some builtin functions as they would
have returned the prior event's data when executed outside of event
draining (e.g. C++ level hook invocations), but I think that's actually
for the better.
2025-03-27 19:23:30 +01:00
Arne Welzel
bef923ebeb EventMgr: Drop src_val
This is a left over and hasn't been used since a while.
2025-03-27 11:16:31 +01:00
Arne Welzel
277e6d4129 Event: Header cleanup 2025-03-27 11:16:29 +01:00
Arne Welzel
46acd9168e EventMgr: Remove queue_flare, use GetNextTimeout() instead
It can be visible overhead to call write() on the underlying pipe of the
EventMgr's flare whenever the first event is enqueued during an IO loop
iteration. Particularly in scenarios where there's about 1 event per packet
for long lived connections and script-side event processing is fast.

Given the event manager is drained anyhow at the end of the main loop, this
shouldn't be needed. In fact, the EventMgr.Process() method is basically
a stub. The one reason it is needed is when more events are enqueued during
a drain. That, however, can be dealt with by implementing GetNextTimeout()
to return 0.0 when there's more events queued. This way the main-loop's poll
timeout is 0.0 and it'll continue immediately.

This also allows to removes some extra code and drop the recently introduced
InitPostFork() addition: Without a pipe, there's no need to recreate it.
2023-12-04 20:03:31 +01:00
Benjamin Bannier
f5a76c1aed Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The
one place where we deviate is header include order since Zeek depends on
headers being included in a certain order.
2023-10-30 09:40:55 +01:00
Arne Welzel
d8a0822221 event: Reinitialize EventMgr's flare after fork() from stem
Because EventMgr is defined globally as an object (rather than a global
pointer to an EventMgr object), its pipe is created even before main()
is entered. This further means that in the fork-based supervisor setup,
all Zeek processes created from the top-level supervisor process share
the same pipe object for the EventMgr. In turn, whenever any of the
processes enqueued an event, the flare was fired and ready for reading
on all other processes in the cluster, causing much contention and
unneeded overhead.

Closes #3190
2023-10-20 17:52:48 +02:00
Arne Welzel
11776d60e0 Merge remote-tracking branch 'jgras/topic/jgras/event-ts'
* jgras/topic/jgras/event-ts:
  Add compatibility tests for timestamped events.
  Add timestamps to auto published broker events.
  Add timestamps to manually published broker events.
  Annotate scheduled events with intended timestamp.
  Add timestamp to events.

One timestamp to ts rename during the merge.
2023-05-11 14:02:08 +02:00
Jan Grashoefer
ae152f1777 Annotate scheduled events with intended timestamp. 2023-05-11 12:51:06 +02:00
Jan Grashoefer
fa84d2896a Add timestamp to events. 2023-05-11 12:51:06 +02:00
Tim Wojtulewicz
b2f171ec69 Reformat the world 2021-09-16 15:35:39 -07:00
Tim Wojtulewicz
4ad08172d0 Remove obsolete ZEEK_FORWARD_DECLARE_NAMESPACED macros 2021-02-24 14:35:44 -07:00
Tim Wojtulewicz
0618be792f Remove all of the random single-file deprecations
These are the changes that don't require a ton of changes to other files outside
of the original removal.
2021-01-27 10:52:40 -07:00
Tim Wojtulewicz
96d9115360 GH-1079: Use full paths starting with zeek/ when including files 2020-11-12 12:15:26 -07:00
Tim Wojtulewicz
fe0c22c789 Base: Clean up explicit uses of namespaces in places where they're not necessary.
This commit covers all of the common and base classes.
2020-08-24 12:07:00 -07:00
Tim Wojtulewicz
01ce18894b Rename types in ZeekList.h to be consistent with the style guide 2020-08-20 16:11:47 -07:00
Tim Wojtulewicz
106a92a9a8 Rename BroList.h to ZeekList.h 2020-08-20 16:11:46 -07:00
Tim Wojtulewicz
ddf48d7529 Move a few of the zeek::util methods and variables to zeek::util::detail 2020-08-20 16:11:44 -07:00
Tim Wojtulewicz
8d2d867a65 Move everything in util.h to zeek::util namespace.
This commit includes renaming a number of methods prefixed with bro_ to be prefixed with zeek_.
2020-08-20 16:00:33 -07:00
Tim Wojtulewicz
45b5a98420 Move EventMgr, EventHandler, and EventRegistry code to zeek namespace. Rename mgr to event_mgr. 2020-07-31 16:23:32 -04:00
Tim Wojtulewicz
1c17700c48 Move Timer and PriorityQueue classes to namespaces 2020-07-31 16:23:02 -04:00
Tim Wojtulewicz
9400b863ea Move all base analyzer classes to zeek::analyzer namespace 2020-07-31 16:21:46 -04:00
Tim Wojtulewicz
02cef05f93 Rename BroObj to Obj 2020-07-02 16:15:01 -07:00
Tim Wojtulewicz
40ecede4ea Move Location to zeek::detail and BroObj to zeek 2020-06-30 21:12:26 -07:00
Tim Wojtulewicz
64332ca22c Move all Val classes to the zeek namespaces 2020-06-30 20:48:09 -07:00
Tim Wojtulewicz
ec9eff0bd5 Use type aliases for IntrusivePtr definitions 2020-06-30 20:37:30 -07:00
Tim Wojtulewicz
9364e6a5b7 Move IntrusivePtr and utility methods to the zeek namespace 2020-06-30 20:19:12 -07:00
Tim Wojtulewicz
4a1b39a2be Move Flare/Pipe from the bro namespace to zeek::detail 2020-06-03 15:16:19 -07:00
Johanna Amann
a3a38f0849 Merge remote-tracking branch 'origin/topic/timw/nullptr'
* origin/topic/timw/nullptr:
  The remaining nulls
  plugin/probabilistic/zeekygen: Replace nulls with nullptr
  file_analysis: Replace nulls with nullptr
  analyzer: Replace nulls with nullptr
  iosource/threading/input/logging: Replace nulls with nullptr
2020-04-09 08:59:53 -07:00
Tim Wojtulewicz
0a47588d0b The remaining nulls 2020-04-07 16:08:34 -07:00
Tim Wojtulewicz
4035ec7760 More final markings.
These classes were recommended by gcc's -Wsugggest-final-types as places where
large numbers of virtual functions could be optimized away.
2020-04-03 18:35:24 -04:00
Tim Wojtulewicz
9c89cd4a47 Mark a large number of common types as final that shouldn't be overrideden 2020-04-03 18:33:51 -04:00
Tim Wojtulewicz
fd5e15b116 The Great Embooleanating
A large number of functions had return values and/or arguments changed
to use ``bool`` types instead of ``int``.
2020-03-31 06:41:54 +00:00
Jon Siwek
599dda9ae9 Fix missing IntrusivePtr.h include and ambiguous ODesc::Add call 2020-03-25 19:37:06 -07:00
Jon Siwek
54bc3bd5c6 Remove TimerMgr arg from event queuing/scheduling methods
It's not useful for anything since there's only ever a single TimerMgr.
2020-03-25 19:05:17 -07:00
Jon Siwek
6980f63a91 Deprecate EventMgr::QueueEventFast() and update usages to Enqueue() 2020-03-25 16:09:33 -07:00
Jon Siwek
0db484cc7a Deprecate EventMgr::QueueEvent() and update usages to Enqueue() 2020-03-25 16:09:33 -07:00
Jon Siwek
4e1ac4e124 Use vector<IntrusivePtr<Val>> for Func::Call and Event queuing args
This change may break BIFs that use @ARGS@, @ARG@, or @ARGC@ since their
types have changed.
2020-03-24 16:50:18 -07:00
Tim Wojtulewicz
4f23c0360a GH-773: Make EventMgr an IOSource so that events interrupt kevent waits 2020-02-05 15:43:37 -05:00