mirror of
https://github.com/zeek/zeek.git
synced 2025-10-11 11:08:20 +00:00
Fix in code for disabling analyzers.
Plus some refactoring. Closes #577.
This commit is contained in:
parent
6ae9da5aad
commit
8fa059fb10
3 changed files with 31 additions and 55 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 241f37597d5fb345dfed5b6b246107d143290851
|
Subproject commit 999a935ccff7c2229cd37d9b117f12dc881f8168
|
|
@ -426,19 +426,7 @@ void Analyzer::ForwardPacket(int len, const u_char* data, bool is_orig,
|
||||||
if ( ! (current->finished || current->removing ) )
|
if ( ! (current->finished || current->removing ) )
|
||||||
current->NextPacket(len, data, is_orig, seq, ip, caplen);
|
current->NextPacket(len, data, is_orig, seq, ip, caplen);
|
||||||
else
|
else
|
||||||
{
|
DeleteChild(--i);
|
||||||
if ( removing )
|
|
||||||
{
|
|
||||||
current->Done();
|
|
||||||
removing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Analyzer has already been disabled so delete it.
|
|
||||||
DBG_LOG(DBG_DPD, "%s deleted child %s",
|
|
||||||
fmt_analyzer(this).c_str(), fmt_analyzer(current).c_str());
|
|
||||||
children.erase(--i);
|
|
||||||
delete current;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendNewChildren();
|
AppendNewChildren();
|
||||||
|
@ -461,19 +449,7 @@ void Analyzer::ForwardStream(int len, const u_char* data, bool is_orig)
|
||||||
if ( ! (current->finished || current->removing ) )
|
if ( ! (current->finished || current->removing ) )
|
||||||
current->NextStream(len, data, is_orig);
|
current->NextStream(len, data, is_orig);
|
||||||
else
|
else
|
||||||
{
|
DeleteChild(--i);
|
||||||
// Analyzer has already been disabled so delete it.
|
|
||||||
if ( current->removing )
|
|
||||||
{
|
|
||||||
current->Done();
|
|
||||||
removing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DBG_LOG(DBG_DPD, "%s deleted child %s",
|
|
||||||
fmt_analyzer(this).c_str(), fmt_analyzer(current).c_str());
|
|
||||||
children.erase(--i);
|
|
||||||
delete current;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendNewChildren();
|
AppendNewChildren();
|
||||||
|
@ -496,19 +472,7 @@ void Analyzer::ForwardUndelivered(int seq, int len, bool is_orig)
|
||||||
if ( ! (current->finished || current->removing ) )
|
if ( ! (current->finished || current->removing ) )
|
||||||
current->NextUndelivered(seq, len, is_orig);
|
current->NextUndelivered(seq, len, is_orig);
|
||||||
else
|
else
|
||||||
{
|
DeleteChild(--i);
|
||||||
if ( current->removing )
|
|
||||||
{
|
|
||||||
current->Done();
|
|
||||||
removing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Analyzer has already been disabled so delete it.
|
|
||||||
DBG_LOG(DBG_DPD, "%s deleted child %s",
|
|
||||||
fmt_analyzer(this).c_str(), fmt_analyzer(current).c_str());
|
|
||||||
children.erase(--i);
|
|
||||||
delete current;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendNewChildren();
|
AppendNewChildren();
|
||||||
|
@ -528,19 +492,7 @@ void Analyzer::ForwardEndOfData(bool orig)
|
||||||
if ( ! (current->finished || current->removing ) )
|
if ( ! (current->finished || current->removing ) )
|
||||||
current->NextEndOfData(orig);
|
current->NextEndOfData(orig);
|
||||||
else
|
else
|
||||||
{
|
DeleteChild(--i);
|
||||||
if ( current->removing )
|
|
||||||
{
|
|
||||||
current->Done();
|
|
||||||
removing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Analyzer has already been disabled so delete it.
|
|
||||||
DBG_LOG(DBG_DPD, "%s deleted child %s",
|
|
||||||
fmt_analyzer(this).c_str(), fmt_analyzer(current).c_str());
|
|
||||||
children.erase(--i);
|
|
||||||
delete current;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendNewChildren();
|
AppendNewChildren();
|
||||||
|
@ -606,7 +558,7 @@ void Analyzer::RemoveChildAnalyzer(AnalyzerID id)
|
||||||
LOOP_OVER_CHILDREN(i)
|
LOOP_OVER_CHILDREN(i)
|
||||||
if ( (*i)->id == id && ! ((*i)->finished || (*i)->removing) )
|
if ( (*i)->id == id && ! ((*i)->finished || (*i)->removing) )
|
||||||
{
|
{
|
||||||
DBG_LOG(DBG_DPD, "%s disabled child %s", GetTagName(), id,
|
DBG_LOG(DBG_DPD, "%s disabling child %s", GetTagName(), id,
|
||||||
fmt_analyzer(this).c_str(), fmt_analyzer(*i).c_str());
|
fmt_analyzer(this).c_str(), fmt_analyzer(*i).c_str());
|
||||||
// See comment above.
|
// See comment above.
|
||||||
(*i)->removing = true;
|
(*i)->removing = true;
|
||||||
|
@ -657,6 +609,26 @@ Analyzer* Analyzer::FindChild(AnalyzerTag::Tag arg_tag)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Analyzer::DeleteChild(analyzer_list::iterator i)
|
||||||
|
{
|
||||||
|
Analyzer* child = *i;
|
||||||
|
|
||||||
|
// Analyzer must have already been finished or marked for removal.
|
||||||
|
assert(child->finished || child->removing);
|
||||||
|
|
||||||
|
if ( child->removing )
|
||||||
|
{
|
||||||
|
child->Done();
|
||||||
|
child->removing = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DBG_LOG(DBG_DPD, "%s deleted child %s 3",
|
||||||
|
fmt_analyzer(this).c_str(), fmt_analyzer(child).c_str());
|
||||||
|
|
||||||
|
children.erase(i);
|
||||||
|
delete child;
|
||||||
|
}
|
||||||
|
|
||||||
void Analyzer::AddSupportAnalyzer(SupportAnalyzer* analyzer)
|
void Analyzer::AddSupportAnalyzer(SupportAnalyzer* analyzer)
|
||||||
{
|
{
|
||||||
if ( HasSupportAnalyzer(analyzer->GetTag(), analyzer->IsOrig()) )
|
if ( HasSupportAnalyzer(analyzer->GetTag(), analyzer->IsOrig()) )
|
||||||
|
|
|
@ -277,6 +277,10 @@ protected:
|
||||||
void AppendNewChildren();
|
void AppendNewChildren();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Internal method to eventually delete a child analyzer that's
|
||||||
|
// already Done().
|
||||||
|
void DeleteChild(analyzer_list::iterator i);
|
||||||
|
|
||||||
AnalyzerTag::Tag tag;
|
AnalyzerTag::Tag tag;
|
||||||
AnalyzerID id;
|
AnalyzerID id;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue