Merge branch 'topic/jgras/fix-future-event-ts' of https://github.com/J-Gras/zeek

* 'topic/jgras/fix-future-event-ts' of https://github.com/J-Gras/zeek:
  Prevent event timestamps set to future
This commit is contained in:
Arne Welzel 2025-04-11 15:16:53 +02:00
commit f1ae944c9c
5 changed files with 21 additions and 7 deletions

View file

@ -1,3 +1,12 @@
7.2.0-dev.510 | 2025-04-11 15:16:53 +0200
* Prevent event timestamps set to future (Jan Grashoefer, Corelight)
For scheduled events, the event timestamp is the intended timestamp. If
we force timer expiration, the timestamp might be in the future. Today,
this happens on shutdown. This change guarantees that event timestamps
are never set beyond network time.
7.2.0-dev.508 | 2025-04-11 12:59:53 +0200 7.2.0-dev.508 | 2025-04-11 12:59:53 +0200
* GH-4301: Fix `--with-spicy`. (Robin Sommer, Corelight) * GH-4301: Fix `--with-spicy`. (Robin Sommer, Corelight)

View file

@ -1 +1 @@
7.2.0-dev.508 7.2.0-dev.510

View file

@ -3829,8 +3829,13 @@ ScheduleTimer::ScheduleTimer(const EventHandlerPtr& arg_event, Args arg_args, do
: Timer(t, TIMER_SCHEDULE), event(arg_event), args(std::move(arg_args)) {} : Timer(t, TIMER_SCHEDULE), event(arg_event), args(std::move(arg_args)) {}
void ScheduleTimer::Dispatch(double /* t */, bool /* is_expire */) { void ScheduleTimer::Dispatch(double /* t */, bool /* is_expire */) {
if ( event ) if ( event ) {
event_mgr.Enqueue(event, std::move(args), util::detail::SOURCE_LOCAL, 0, nullptr, this->Time()); // An event's intended timestamp might be in the past as timer expiration is driven by
// network time. Guarantee that the intended timestamp is never in the future (e.g.,
// when all timers are expired on shutdown).
auto ts = std::min(this->Time(), run_state::network_time);
event_mgr.Enqueue(event, std::move(args), util::detail::SOURCE_LOCAL, 0, nullptr, ts);
}
} }
ScheduleExpr::ScheduleExpr(ExprPtr arg_when, EventExprPtr arg_event) ScheduleExpr::ScheduleExpr(ExprPtr arg_when, EventExprPtr arg_event)

View file

@ -39,5 +39,5 @@ sender added peer: endpoint=127.0.0.1 msg=handshake successful
>> Run 10 (1989-12-13-07:00:00) >> Run 10 (1989-12-13-07:00:00)
>>> Publish my-message-a intended for 1989-12-13-07:00:00 (current_event_time=1989-12-13-07:00:00, network_time=1989-12-13-07:00:00) >>> Publish my-message-a intended for 1989-12-13-07:00:00 (current_event_time=1989-12-13-07:00:00, network_time=1989-12-13-07:00:00)
sender lost peer: endpoint=127.0.0.1 msg=lost connection to remote peer sender lost peer: endpoint=127.0.0.1 msg=lost connection to remote peer
>>> Publish my-message-b intended for 1989-12-13-07:15:00 (current_event_time=1989-12-13-07:15:00, network_time=1989-12-13-07:00:00) >>> Publish my-message-b intended for 1989-12-13-07:15:00 (current_event_time=1989-12-13-07:00:00, network_time=1989-12-13-07:00:00)
>>> Publish my-message-c intended for 1989-12-13-07:30:00 (current_event_time=1989-12-13-07:30:00, network_time=1989-12-13-07:00:00) >>> Publish my-message-c intended for 1989-12-13-07:30:00 (current_event_time=1989-12-13-07:00:00, network_time=1989-12-13-07:00:00)

View file

@ -37,5 +37,5 @@
[1989-12-13-07:00:00] Test was scheduled at 1989-12-13-06:00:00 for 1989-12-13-06:30:00 [1989-12-13-07:00:00] Test was scheduled at 1989-12-13-06:00:00 for 1989-12-13-06:30:00
>> Run 9 (1989-12-13-07:00:00) >> Run 9 (1989-12-13-07:00:00)
<< Run 9 (1989-12-13-07:00:00) << Run 9 (1989-12-13-07:00:00)
[1989-12-13-07:00:00] Test was scheduled at 1989-12-13-07:00:00 for 1989-12-13-07:15:00 [1989-12-13-07:00:00] Test was scheduled at 1989-12-13-07:00:00 for 1989-12-13-07:00:00
[1989-12-13-07:00:00] Test was scheduled at 1989-12-13-07:00:00 for 1989-12-13-07:30:00 [1989-12-13-07:00:00] Test was scheduled at 1989-12-13-07:00:00 for 1989-12-13-07:00:00