mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
Fixed table expiration evaluation.
The expiration attribute expression is now evaluated for every use. Thus later adjustments of the value (e.g. by redefining a const) will now take effect. Values less than 0 will disable expiration.
This commit is contained in:
parent
f662989c09
commit
8a87055fcc
4 changed files with 98 additions and 31 deletions
5
testing/btest/Baseline/language.expire-redef/output
Normal file
5
testing/btest/Baseline/language.expire-redef/output
Normal file
|
@ -0,0 +1,5 @@
|
|||
Run 0
|
||||
Run 1
|
||||
Run 2
|
||||
Expired: 0 --> some data
|
||||
Run 3
|
38
testing/btest/language/expire-redef.bro
Normal file
38
testing/btest/language/expire-redef.bro
Normal file
|
@ -0,0 +1,38 @@
|
|||
# @TEST-EXEC: btest-bg-run broproc bro %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait -k 5
|
||||
# @TEST-EXEC: cat broproc/.stdout > output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
|
||||
@load frameworks/communication/listen
|
||||
|
||||
const exp_val = -1sec &redef;
|
||||
|
||||
global expired: function(tbl: table[int] of string, idx: int): interval;
|
||||
global data: table[int] of string &write_expire=exp_val &expire_func=expired;
|
||||
|
||||
redef table_expire_interval = 1sec;
|
||||
redef exp_val = 3sec;
|
||||
|
||||
global runs = 0;
|
||||
event do_it()
|
||||
{
|
||||
print fmt("Run %s", runs);
|
||||
|
||||
++runs;
|
||||
if ( runs < 4 )
|
||||
schedule 1sec { do_it() };
|
||||
}
|
||||
|
||||
|
||||
function expired(tbl: table[int] of string, idx: int): interval
|
||||
{
|
||||
print fmt("Expired: %s --> %s", idx, tbl[idx]);
|
||||
return 0sec;
|
||||
}
|
||||
|
||||
event bro_init() &priority=-10
|
||||
{
|
||||
data[0] = "some data";
|
||||
schedule 1sec { do_it() };
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue