mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix race condition in scripts.base.frameworks.input.invalid*
The invalidset and invalidtext tests loaded an input file via table and event reads, in parallel. On FreeBSD this triggers an occasional reordering of messages coming out of the reader thread vs the input managers. This commit makes the table and event reads sequential, avoiding the race.
This commit is contained in:
parent
8bcaa64d8f
commit
4e75662963
2 changed files with 14 additions and 2 deletions
|
@ -50,13 +50,19 @@ event zeek_init()
|
||||||
outfile = open("../out");
|
outfile = open("../out");
|
||||||
# first read in the old stuff into the table...
|
# first read in the old stuff into the table...
|
||||||
Input::add_table([$source="../input.log", $name="ssh", $error_ev=handle_our_errors, $idx=Idx, $val=Val, $destination=servers]);
|
Input::add_table([$source="../input.log", $name="ssh", $error_ev=handle_our_errors, $idx=Idx, $val=Val, $destination=servers]);
|
||||||
Input::add_event([$source="../input.log", $name="sshevent", $error_ev=handle_our_errors_event, $fields=Val, $want_record=T, $ev=line]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Input::end_of_data(name: string, source:string)
|
event Input::end_of_data(name: string, source:string)
|
||||||
{
|
{
|
||||||
++endcount;
|
++endcount;
|
||||||
|
|
||||||
|
# ... and when we're done, move to reading via events.
|
||||||
|
# This makes the reads sequential, avoding races in the output.
|
||||||
|
if ( endcount == 1 )
|
||||||
|
{
|
||||||
|
Input::add_event([$source="../input.log", $name="sshevent", $error_ev=handle_our_errors_event, $fields=Val, $want_record=T, $ev=line]);
|
||||||
|
}
|
||||||
|
|
||||||
if ( endcount == 2 )
|
if ( endcount == 2 )
|
||||||
{
|
{
|
||||||
print outfile, servers;
|
print outfile, servers;
|
||||||
|
|
|
@ -51,13 +51,19 @@ event zeek_init()
|
||||||
outfile = open("../out");
|
outfile = open("../out");
|
||||||
# first read in the old stuff into the table...
|
# first read in the old stuff into the table...
|
||||||
Input::add_table([$source="../input.log", $name="ssh", $error_ev=handle_our_errors, $idx=Idx, $val=Val, $destination=servers]);
|
Input::add_table([$source="../input.log", $name="ssh", $error_ev=handle_our_errors, $idx=Idx, $val=Val, $destination=servers]);
|
||||||
Input::add_event([$source="../input.log", $name="sshevent", $error_ev=handle_our_errors_event, $fields=Val, $want_record=T, $ev=line]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
event Input::end_of_data(name: string, source:string)
|
event Input::end_of_data(name: string, source:string)
|
||||||
{
|
{
|
||||||
++endcount;
|
++endcount;
|
||||||
|
|
||||||
|
# ... and when we're done, move to reading via events.
|
||||||
|
# This makes the reads sequential, avoding races in the output.
|
||||||
|
if ( endcount == 1 )
|
||||||
|
{
|
||||||
|
Input::add_event([$source="../input.log", $name="sshevent", $error_ev=handle_our_errors_event, $fields=Val, $want_record=T, $ev=line]);
|
||||||
|
}
|
||||||
|
|
||||||
if ( endcount == 2 )
|
if ( endcount == 2 )
|
||||||
{
|
{
|
||||||
print outfile, servers;
|
print outfile, servers;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue