TimerMgr: Add back max_timer_expires=0 special case

Commit 58fae22708 removed the max_expire==0
handling from DoAdvance() due to not being obvious what use it is. Jan
later reported that it broke the `redef max_timer_expires=0` (#2514).

This commit adds back the special case re-introducing the `max_timer_expires=0` ,
trying to make it fairly explicit that it exists.

This is an adaption of #2516 not adding a new option and trying a bit
to avoid global variable accesses down in DoAdvance(), though that
just moved to InitPostScript().

Fixes #2514.
This commit is contained in:
Arne Welzel 2022-11-24 11:29:04 +01:00
parent 8cdc3e4374
commit 2becb1337f
3 changed files with 11 additions and 4 deletions

View file

@ -111,6 +111,8 @@ void TimerMgr::InitPostScript()
{
if ( iosource_mgr )
iosource_mgr->Register(this, true);
dispatch_all_expired = zeek::detail::max_timer_expires == 0;
}
void TimerMgr::Add(Timer* timer)
@ -142,7 +144,8 @@ void TimerMgr::Expire()
int TimerMgr::DoAdvance(double new_t, int max_expire)
{
Timer* timer = Top();
for ( num_expired = 0; (num_expired < max_expire) && timer && timer->Time() <= new_t;
for ( num_expired = 0;
(num_expired < max_expire || dispatch_all_expired) && timer && timer->Time() <= new_t;
++num_expired )
{
last_timestamp = timer->Time();