mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 05:58:20 +00:00
Fixing memory leaks in input framework.
This commit is contained in:
parent
126fbb6ba9
commit
d81bfed45d
5 changed files with 84 additions and 8 deletions
63
testing/btest/core/leaks/input-with-remove.bro
Normal file
63
testing/btest/core/leaks/input-with-remove.bro
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Needs perftools support.
|
||||
#
|
||||
# @TEST-GROUP: leaks
|
||||
#
|
||||
# @TEST-REQUIRES: bro --help 2>&1 | grep -q mem-leaks
|
||||
#
|
||||
# @TEST-EXEC: HEAP_CHECK_DUMP_DIRECTORY=. HEAPCHECK=local btest-bg-run bro bro -b -m -r $TRACES/wikipedia.trace %INPUT
|
||||
# @TEST-EXEC: btest-bg-wait 15
|
||||
|
||||
@load base/frameworks/input
|
||||
|
||||
redef exit_only_after_terminate = T;
|
||||
|
||||
global c: count = 0;
|
||||
|
||||
|
||||
type OneLine: record {
|
||||
s: string;
|
||||
};
|
||||
|
||||
event line(description: Input::EventDescription, tpe: Input::Event, s: string)
|
||||
{
|
||||
print "1", "Line";
|
||||
}
|
||||
|
||||
event InputRaw::process_finished(name: string, source:string, exit_code:count, signal_exit:bool)
|
||||
{
|
||||
Input::remove(name);
|
||||
print "2", name;
|
||||
}
|
||||
|
||||
function run(): count
|
||||
{
|
||||
Input::add_event([$name=unique_id(""),
|
||||
$source=fmt("%s |", "date"),
|
||||
$reader=Input::READER_RAW,
|
||||
$mode=Input::STREAM,
|
||||
$fields=OneLine,
|
||||
$ev=line,
|
||||
$want_record=F]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
event do()
|
||||
{
|
||||
run();
|
||||
}
|
||||
|
||||
event do_term() {
|
||||
terminate();
|
||||
}
|
||||
|
||||
event bro_init() {
|
||||
schedule 1sec {
|
||||
do()
|
||||
};
|
||||
schedule 3sec {
|
||||
do_term()
|
||||
};
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue