mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 09:38:19 +00:00
Prevent recursion of &on_change handlers.
This change prevents &on_change handlers for a table from running if an &on_change handler for the same table is already running.
This commit is contained in:
parent
7166cb7373
commit
7f9f66fce9
5 changed files with 46 additions and 3 deletions
8
testing/btest/Baseline/language.on_change-recurse/output
Normal file
8
testing/btest/Baseline/language.on_change-recurse/output
Normal file
|
@ -0,0 +1,8 @@
|
|||
inserting
|
||||
change_function, a, 1, 5, TABLE_ELEMENT_NEW
|
||||
set_change, hi, TABLE_ELEMENT_NEW
|
||||
changing
|
||||
change_function, a, 1, 5, TABLE_ELEMENT_CHANGED
|
||||
deleting
|
||||
change_function, a, 1, 5, TABLE_ELEMENT_REMOVED
|
||||
set_change, hi, TABLE_ELEMENT_REMOVED
|
30
testing/btest/language/on_change-recurse.test
Normal file
30
testing/btest/language/on_change-recurse.test
Normal file
|
@ -0,0 +1,30 @@
|
|||
# @TEST-EXEC: zeek %INPUT >output
|
||||
# @TEST-EXEC: btest-diff output
|
||||
|
||||
module TestModule;
|
||||
|
||||
function change_function(t: table[string, int] of count, tpe: TableChange, idxa: string, idxb: int, val: count)
|
||||
{
|
||||
print "change_function", idxa, idxb, val, tpe;
|
||||
t[idxa, idxb] = val;
|
||||
}
|
||||
|
||||
function set_change(t: set[string], tpe: TableChange, idx: string)
|
||||
{
|
||||
print "set_change", idx, tpe;
|
||||
}
|
||||
|
||||
global t: table[string, int] of count &on_change=change_function;
|
||||
global s: set[string] &on_change=set_change;
|
||||
|
||||
event zeek_init()
|
||||
{
|
||||
print "inserting";
|
||||
t["a", 1] = 5;
|
||||
add s["hi"];
|
||||
print "changing";
|
||||
t["a", 1] = 2;
|
||||
print "deleting";
|
||||
delete t["a", 1];
|
||||
delete s["hi"];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue