mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
TableVal: Propagate &on_change attribute through copy()
Mostly for consistency with &default, &expire_func and other attributes being propagated through a copy(). Seems this was just missed during the implementation and/or was never tested for.
This commit is contained in:
parent
2b5db43270
commit
b2c4f8fd92
4 changed files with 46 additions and 0 deletions
3
NEWS
3
NEWS
|
@ -20,6 +20,9 @@ Changed Functionality
|
||||||
an appropriate callback function, log a warning and return a generic handle
|
an appropriate callback function, log a warning and return a generic handle
|
||||||
value based on the analyzer and connection information.
|
value based on the analyzer and connection information.
|
||||||
|
|
||||||
|
- The ``&on_change`` attribute of set and tables is propagated through ``copy()``.
|
||||||
|
|
||||||
|
|
||||||
Zeek 5.2.0
|
Zeek 5.2.0
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|
|
@ -2649,6 +2649,9 @@ ValPtr TableVal::DoClone(CloneState* state)
|
||||||
detail::timer_mgr->Add(tv->timer);
|
detail::timer_mgr->Add(tv->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( change_func )
|
||||||
|
tv->change_func = change_func;
|
||||||
|
|
||||||
if ( expire_func )
|
if ( expire_func )
|
||||||
tv->expire_func = expire_func;
|
tv->expire_func = expire_func;
|
||||||
|
|
||||||
|
|
9
testing/btest/Baseline/language.on_change-copy/output
Normal file
9
testing/btest/Baseline/language.on_change-copy/output
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
|
inserting
|
||||||
|
tbl_change, a, 1, 5, TABLE_ELEMENT_NEW
|
||||||
|
set_change, hi, TABLE_ELEMENT_NEW
|
||||||
|
changing
|
||||||
|
tbl_change, a, 1, 5, TABLE_ELEMENT_CHANGED
|
||||||
|
deleting
|
||||||
|
tbl_change, a, 1, 2, TABLE_ELEMENT_REMOVED
|
||||||
|
set_change, hi, TABLE_ELEMENT_REMOVED
|
31
testing/btest/language/on_change-copy.test
Normal file
31
testing/btest/language/on_change-copy.test
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# @TEST-EXEC: zeek -b %INPUT >output
|
||||||
|
# @TEST-EXEC: btest-diff output
|
||||||
|
|
||||||
|
module TestModule;
|
||||||
|
|
||||||
|
function tbl_change(t: table[string, int] of count, tpe: TableChange, idxa: string, idxb: int, val: count)
|
||||||
|
{
|
||||||
|
print "tbl_change", idxa, idxb, val, tpe;
|
||||||
|
}
|
||||||
|
|
||||||
|
function set_change(t: set[string], tpe: TableChange, idx: string)
|
||||||
|
{
|
||||||
|
print "set_change", idx, tpe;
|
||||||
|
}
|
||||||
|
|
||||||
|
global t: table[string, int] of count &on_change=tbl_change;
|
||||||
|
global s: set[string] &on_change=set_change;
|
||||||
|
|
||||||
|
event zeek_init()
|
||||||
|
{
|
||||||
|
local tc = copy(t);
|
||||||
|
local sc = copy(s);
|
||||||
|
print "inserting";
|
||||||
|
tc["a", 1] = 5;
|
||||||
|
add sc["hi"];
|
||||||
|
print "changing";
|
||||||
|
tc["a", 1] = 2;
|
||||||
|
print "deleting";
|
||||||
|
delete tc["a", 1];
|
||||||
|
delete sc["hi"];
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue