mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00

Due to the asynchronous behavior of the input framework and broker communication, change handlers were previously called even after zeek_done() event processing completed and also broker shutdown. Accessing broker store handles within change handlers this late triggered invalid Broker store handle messages: error in ././my_option_store.zeek, line 13: invalid Broker store handle (Broker::put(Test::store, to_any_coercemy_option, to_any_coerceTest::new_value, 0 secs) and broker::store::{}) Fixes #2010
29 lines
780 B
Text
29 lines
780 B
Text
# @TEST-DOC: Ensure change handlers do not run when terminating by trying to change an option during zeek_done()
|
|
# @TEST-EXEC: zeek -b %INPUT
|
|
# @TEST-EXEC: btest-diff .stdout
|
|
|
|
export {
|
|
option testbool: bool = T;
|
|
}
|
|
|
|
function option_changed(ID: string, new_value: bool): bool {
|
|
print fmt("Value of %s changed from %s to %s (zeek_is_terminating=%s)", ID, testbool, new_value, zeek_is_terminating());
|
|
return new_value;
|
|
}
|
|
|
|
event zeek_init()
|
|
{
|
|
print "Initial value", testbool;
|
|
Option::set_change_handler("testbool", option_changed);
|
|
local changed = Option::set("testbool", F);
|
|
print "Next value", testbool;
|
|
print "Next changed", changed;
|
|
}
|
|
|
|
event zeek_done()
|
|
{
|
|
local changed = Option::set("testbool", T);
|
|
print "Final value", testbool;
|
|
print "Final changed", changed;
|
|
}
|
|
|