mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Prevent event timestamps set to future
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.
This commit is contained in:
parent
3b478ddc0a
commit
3858a2920e
3 changed files with 11 additions and 6 deletions
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue