Merge remote-tracking branch 'origin/fastpath'

* origin/fastpath:
  Small (potential performance) improvement for logging framework.
  Script-level rotation postprocessor fix.
  update input framework documentation to reflect want_record change.
  Fix crash when encountering an InterpreterException in a predicate in logging or input Framework.
  make want_record=T the default for events
This commit is contained in:
Robin Sommer 2012-07-27 12:22:03 -07:00
commit c66c6d7c46
12 changed files with 51 additions and 39 deletions

19
CHANGES
View file

@ -1,4 +1,23 @@
2.0-898 | 2012-07-27 12:22:03 -0700
* Small (potential performance) improvement for logging framework. (Seth Hall)
* Script-level rotation postprocessor fix. This fixes a problem with
writers that don't have a postprocessor. (Seth Hall)
* Update input framework documentation to reflect want_record
change. (Bernhard Amann)
* Fix crash when encountering an InterpreterException in a predicate
in logging or input Framework. (Bernhard Amann)
* Input framework: Make want_record=T the default for events
(Bernhard Amann)
* Changing the start/end markers in logs to open/close now
reflecting wall clock. (Robin Sommer)
2.0-891 | 2012-07-26 17:15:10 -0700 2.0-891 | 2012-07-26 17:15:10 -0700
* Reader/writer API: preventing plugins from receiving further * Reader/writer API: preventing plugins from receiving further

View file

@ -1 +1 @@
2.0-891 2.0-898

View file

@ -82,11 +82,11 @@ export {
## Record describing the fields to be retrieved from the source input. ## Record describing the fields to be retrieved from the source input.
fields: any; fields: any;
## If want_record if false (default), the event receives each value in fields as a seperate argument. ## If want_record if false, the event receives each value in fields as a separate argument.
## If it is set to true, the event receives all fields in a signle record value. ## If it is set to true (default), the event receives all fields in a single record value.
want_record: bool &default=F; want_record: bool &default=T;
## The event that is rised each time a new line is received from the reader. ## The event that is raised each time a new line is received from the reader.
## The event will receive an Input::Event enum as the first element, and the fields as the following arguments. ## The event will receive an Input::Event enum as the first element, and the fields as the following arguments.
ev: any; ev: any;

View file

@ -341,22 +341,23 @@ function __default_rotation_postprocessor(info: RotationInfo) : bool
{ {
if ( info$writer in default_rotation_postprocessors ) if ( info$writer in default_rotation_postprocessors )
return default_rotation_postprocessors[info$writer](info); return default_rotation_postprocessors[info$writer](info);
else
return F; # Return T by default so that postprocessor-less writers don't shutdown.
return T;
} }
function default_path_func(id: ID, path: string, rec: any) : string function default_path_func(id: ID, path: string, rec: any) : string
{ {
# The suggested path value is a previous result of this function
# or a filter path explicitly set by the user, so continue using it.
if ( path != "" )
return path;
local id_str = fmt("%s", id); local id_str = fmt("%s", id);
local parts = split1(id_str, /::/); local parts = split1(id_str, /::/);
if ( |parts| == 2 ) if ( |parts| == 2 )
{ {
# The suggested path value is a previous result of this function
# or a filter path explicitly set by the user, so continue using it.
if ( path != "" )
return path;
# Example: Notice::LOG -> "notice" # Example: Notice::LOG -> "notice"
if ( parts[2] == "LOG" ) if ( parts[2] == "LOG" )
{ {

View file

@ -1546,7 +1546,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value* *vals)
bool Manager::CallPred(Func* pred_func, const int numvals, ...) bool Manager::CallPred(Func* pred_func, const int numvals, ...)
{ {
bool result; bool result = false;
val_list vl(numvals); val_list vl(numvals);
va_list lP; va_list lP;
@ -1557,10 +1557,13 @@ bool Manager::CallPred(Func* pred_func, const int numvals, ...)
va_end(lP); va_end(lP);
Val* v = pred_func->Call(&vl); Val* v = pred_func->Call(&vl);
result = v->AsBool(); if ( v )
Unref(v); {
result = v->AsBool();
Unref(v);
}
return(result); return result;
} }
bool Manager::SendEvent(const string& name, const int num_vals, Value* *vals) bool Manager::SendEvent(const string& name, const int num_vals, Value* *vals)

View file

@ -686,16 +686,13 @@ bool Manager::Write(EnumVal* id, RecordVal* columns)
int result = 1; int result = 1;
try Val* v = filter->pred->Call(&vl);
if ( v )
{ {
Val* v = filter->pred->Call(&vl);
result = v->AsBool(); result = v->AsBool();
Unref(v); Unref(v);
} }
catch ( InterpreterException& e )
{ /* Already reported. */ }
if ( ! result ) if ( ! result )
continue; continue;
} }
@ -726,15 +723,10 @@ bool Manager::Write(EnumVal* id, RecordVal* columns)
Val* v = 0; Val* v = 0;
try v = filter->path_func->Call(&vl);
{
v = filter->path_func->Call(&vl);
}
catch ( InterpreterException& e ) if ( ! v )
{
return false; return false;
}
if ( ! v->Type()->Tag() == TYPE_STRING ) if ( ! v->Type()->Tag() == TYPE_STRING )
{ {
@ -1382,16 +1374,13 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
int result = 0; int result = 0;
try Val* v = func->Call(&vl);
if ( v )
{ {
Val* v = func->Call(&vl);
result = v->AsBool(); result = v->AsBool();
Unref(v); Unref(v);
} }
catch ( InterpreterException& e )
{ /* Already reported. */ }
return result; return result;
} }

View file

@ -51,6 +51,6 @@ event bro_init()
{ {
try = 0; try = 0;
outfile = open("../out"); outfile = open("../out");
Input::add_event([$source="../input.log", $name="input", $fields=Val, $ev=line]); Input::add_event([$source="../input.log", $name="input", $fields=Val, $ev=line, $want_record=F]);
Input::remove("input"); Input::remove("input");
} }

View file

@ -49,6 +49,6 @@ event bro_init()
{ {
try = 0; try = 0;
outfile = open("../out"); outfile = open("../out");
Input::add_event([$source="../input.log", $name="input", $fields=Val, $ev=line]); Input::add_event([$source="../input.log", $name="input", $fields=Val, $ev=line, $want_record=F]);
Input::remove("input"); Input::remove("input");
} }

View file

@ -37,6 +37,6 @@ event line(description: Input::EventDescription, tpe: Input::Event, s: string)
event bro_init() event bro_init()
{ {
outfile = open("../out.tmp"); outfile = open("../out.tmp");
Input::add_event([$source="wc -l ../input.log |", $reader=Input::READER_RAW, $name="input", $fields=Val, $ev=line]); Input::add_event([$source="wc -l ../input.log |", $reader=Input::READER_RAW, $name="input", $fields=Val, $ev=line, $want_record=F]);
Input::remove("input"); Input::remove("input");
} }

View file

@ -44,6 +44,6 @@ event bro_init()
{ {
try = 0; try = 0;
outfile = open("../out"); outfile = open("../out");
Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::STREAM, $name="input", $fields=Val, $ev=line]); Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::STREAM, $name="input", $fields=Val, $ev=line, $want_record=F]);
Input::remove("input"); Input::remove("input");
} }

View file

@ -44,7 +44,7 @@ event bro_init()
{ {
try = 0; try = 0;
outfile = open("../out"); outfile = open("../out");
Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::REREAD, $name="input", $fields=Val, $ev=line]); Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::REREAD, $name="input", $fields=Val, $ev=line, $want_record=F]);
Input::force_update("input"); Input::force_update("input");
Input::remove("input"); Input::remove("input");
} }

View file

@ -58,5 +58,5 @@ event bro_init()
{ {
outfile = open("../out"); outfile = open("../out");
try = 0; try = 0;
Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::STREAM, $name="input", $fields=Val, $ev=line]); Input::add_event([$source="../input.log", $reader=Input::READER_RAW, $mode=Input::STREAM, $name="input", $fields=Val, $ev=line, $want_record=F]);
} }