mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
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:
parent
8cdc3e4374
commit
2becb1337f
3 changed files with 11 additions and 4 deletions
|
@ -2116,7 +2116,7 @@ global discarder_check_icmp: function(p: pkt_hdr): bool;
|
||||||
## Zeek's watchdog interval.
|
## Zeek's watchdog interval.
|
||||||
const watchdog_interval = 10 sec &redef;
|
const watchdog_interval = 10 sec &redef;
|
||||||
|
|
||||||
## The maximum number of timers to expire after processing each new
|
## The maximum number of expired timers to process after processing each new
|
||||||
## packet. The value trades off spreading out the timer expiration load
|
## packet. The value trades off spreading out the timer expiration load
|
||||||
## with possibly having to hold state longer. A value of 0 means
|
## with possibly having to hold state longer. A value of 0 means
|
||||||
## "process all expired timers with each new packet".
|
## "process all expired timers with each new packet".
|
||||||
|
|
|
@ -111,6 +111,8 @@ void TimerMgr::InitPostScript()
|
||||||
{
|
{
|
||||||
if ( iosource_mgr )
|
if ( iosource_mgr )
|
||||||
iosource_mgr->Register(this, true);
|
iosource_mgr->Register(this, true);
|
||||||
|
|
||||||
|
dispatch_all_expired = zeek::detail::max_timer_expires == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerMgr::Add(Timer* timer)
|
void TimerMgr::Add(Timer* timer)
|
||||||
|
@ -142,7 +144,8 @@ void TimerMgr::Expire()
|
||||||
int TimerMgr::DoAdvance(double new_t, int max_expire)
|
int TimerMgr::DoAdvance(double new_t, int max_expire)
|
||||||
{
|
{
|
||||||
Timer* timer = Top();
|
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 )
|
++num_expired )
|
||||||
{
|
{
|
||||||
last_timestamp = timer->Time();
|
last_timestamp = timer->Time();
|
||||||
|
|
|
@ -84,7 +84,8 @@ public:
|
||||||
void Add(Timer* timer);
|
void Add(Timer* timer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advance the clock to time t, expiring at most max_expire timers.
|
* Advance the clock to time t, dispatching at most max_expire expired
|
||||||
|
* timers, or all expired timers if dispatch_all_expired is set.
|
||||||
*
|
*
|
||||||
* @param t the new time.
|
* @param t the new time.
|
||||||
* @param max_expire the maximum number of timers to expire.
|
* @param max_expire the maximum number of timers to expire.
|
||||||
|
@ -152,6 +153,9 @@ private:
|
||||||
double last_advance;
|
double last_advance;
|
||||||
|
|
||||||
int num_expired;
|
int num_expired;
|
||||||
|
// Flag to indicate if Advance() should dispatch all expired timers
|
||||||
|
// for the max_timer_expires=0 case.
|
||||||
|
bool dispatch_all_expired = false;
|
||||||
|
|
||||||
size_t peak_size = 0;
|
size_t peak_size = 0;
|
||||||
size_t cumulative_num = 0;
|
size_t cumulative_num = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue