FileAnalysis: optimize get_file_handle event queueing.

When a file handle is needed and the last event in the queue is also
a get_file_handle event with the same arguments, instead of queueing
a new event, just remember to cache/re-use the resulting handle from
the previous event.  This depends on get_file_handle handlers not
changing global state that is also used to derive the file handle
string.
This commit is contained in:
Jon Siwek 2013-04-02 16:21:51 -05:00
parent 390358b70c
commit fc267d010d
10 changed files with 88 additions and 37 deletions

View file

@ -18,9 +18,6 @@ export {
local info: FTP::Info = ftp_data_expected[c$id$resp_h, c$id$resp_p];
local rval = fmt("%s %s %s", ANALYZER_FTP_DATA, c$start_time,
id_string(c$id));
if ( info$passive )
# FTP client initiates data channel.
if ( is_orig )
@ -28,12 +25,14 @@ export {
return "";
else
# Do care about FTP server data.
return rval;
return cat(ANALYZER_FTP_DATA, " ", c$start_time, " ",
id_string(c$id));
else
# FTP server initiates dta channel.
if ( is_orig )
# Do care about FTP server data.
return rval;
return cat(ANALYZER_FTP_DATA, " ", c$start_time, " ",
id_string(c$id));
else
# Don't care about FTP client data.
return "";

View file

@ -18,11 +18,11 @@ export {
if ( ! c?$http ) return "";
if ( c$http$range_request )
return fmt("%s %s %s %s", ANALYZER_HTTP, is_orig, c$id$orig_h,
build_url(c$http));
return cat(ANALYZER_HTTP, " ", is_orig, " ", c$id$orig_h,
" ", build_url(c$http));
return fmt("%s %s %s %s %s", ANALYZER_HTTP, c$start_time, is_orig,
c$http$trans_depth, id_string(c$id));
return cat(ANALYZER_HTTP, " ", c$start_time, " ", is_orig,
" ", c$http$trans_depth, " ", id_string(c$id));
}
}

View file

@ -15,7 +15,7 @@ export {
function get_file_handle(c: connection, is_orig: bool): string
{
if ( is_orig ) return "";
return fmt("%s %s %s", ANALYZER_IRC_DATA, c$start_time,
return cat(ANALYZER_IRC_DATA, " ", c$start_time, " ",
id_string(c$id));
}
}

View file

@ -17,8 +17,8 @@ export {
{
if ( ! c?$smtp ) return "";
return fmt("%s %s %s %s", ANALYZER_SMTP, c$start_time,
c$smtp$trans_depth, c$smtp_state$mime_level);
return cat(ANALYZER_SMTP, " ", c$start_time, " ",
c$smtp$trans_depth, " ", c$smtp_state$mime_level);
}
}