mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48: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
7
CHANGES
7
CHANGES
|
@ -1,4 +1,11 @@
|
|||
|
||||
2.2-140 | 2014-02-06 17:58:04 -0800
|
||||
|
||||
* Fixing memory leaks in input framework. (Robin Sommer)
|
||||
|
||||
* Add script to detect filtered TCP traces. Addresses BIT-1119. (Jon
|
||||
Siwek)
|
||||
|
||||
2.2-137 | 2014-02-04 09:09:55 -0800
|
||||
|
||||
* Minor unified2 script documentation fix. (Jon Siwek)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
2.2-137
|
||||
2.2-140
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 23ff11bf0edbad2c6f1acbeb3f9a029ff4b61785
|
||||
Subproject commit 808fd764b6f5198264177822db3f902f747c21cc
|
|
@ -397,7 +397,9 @@ bool Manager::CreateEventStream(RecordVal* fval)
|
|||
string stream_name = name_val->AsString()->CheckString();
|
||||
Unref(name_val);
|
||||
|
||||
RecordType *fields = fval->Lookup("fields", true)->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
Val* fields_val = fval->Lookup("fields", true);
|
||||
RecordType *fields = fields_val->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
Unref(fields_val);
|
||||
|
||||
Val *want_record = fval->Lookup("want_record", true);
|
||||
|
||||
|
@ -548,13 +550,17 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
|||
|
||||
Val* pred = fval->Lookup("pred", true);
|
||||
|
||||
RecordType *idx = fval->Lookup("idx", true)->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
Val* idx_val = fval->Lookup("idx", true);
|
||||
RecordType *idx = idx_val->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
Unref(idx_val);
|
||||
|
||||
RecordType *val = 0;
|
||||
|
||||
if ( fval->Lookup("val", true) != 0 )
|
||||
Val* val_val = fval->Lookup("val", true);
|
||||
if ( val_val )
|
||||
{
|
||||
val = fval->Lookup("val", true)->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
Unref(val); // The lookupwithdefault in the if-clause ref'ed val.
|
||||
val = val_val->AsType()->AsTypeType()->Type()->AsRecordType();
|
||||
Unref(val_val);
|
||||
}
|
||||
|
||||
TableVal *dst = fval->Lookup("destination", true)->AsTableVal();
|
||||
|
@ -729,7 +735,7 @@ bool Manager::CreateTableStream(RecordVal* fval)
|
|||
stream->pred = pred ? pred->AsFunc() : 0;
|
||||
stream->num_idx_fields = idxfields;
|
||||
stream->num_val_fields = valfields;
|
||||
stream->tab = dst->AsTableVal();
|
||||
stream->tab = dst->AsTableVal(); // ref'd by lookupwithdefault
|
||||
stream->rtype = val ? val->AsRecordType() : 0;
|
||||
stream->itype = idx->AsRecordType();
|
||||
stream->event = event ? event_registry->Lookup(event->Name()) : 0;
|
||||
|
|
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