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 ) )
|
||||
current->NextPacket(len, data, is_orig, seq, ip, caplen);
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
DeleteChild(--i);
|
||||
}
|
||||
|
||||
AppendNewChildren();
|
||||
|
@ -461,19 +449,7 @@ void Analyzer::ForwardStream(int len, const u_char* data, bool is_orig)
|
|||
if ( ! (current->finished || current->removing ) )
|
||||
current->NextStream(len, data, is_orig);
|
||||
else
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
DeleteChild(--i);
|
||||
}
|
||||
|
||||
AppendNewChildren();
|
||||
|
@ -496,19 +472,7 @@ void Analyzer::ForwardUndelivered(int seq, int len, bool is_orig)
|
|||
if ( ! (current->finished || current->removing ) )
|
||||
current->NextUndelivered(seq, len, is_orig);
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
DeleteChild(--i);
|
||||
}
|
||||
|
||||
AppendNewChildren();
|
||||
|
@ -528,19 +492,7 @@ void Analyzer::ForwardEndOfData(bool orig)
|
|||
if ( ! (current->finished || current->removing ) )
|
||||
current->NextEndOfData(orig);
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
DeleteChild(--i);
|
||||
}
|
||||
|
||||
AppendNewChildren();
|
||||
|
@ -606,7 +558,7 @@ void Analyzer::RemoveChildAnalyzer(AnalyzerID id)
|
|||
LOOP_OVER_CHILDREN(i)
|
||||
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());
|
||||
// See comment above.
|
||||
(*i)->removing = true;
|
||||
|
@ -657,6 +609,26 @@ Analyzer* Analyzer::FindChild(AnalyzerTag::Tag arg_tag)
|
|||
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)
|
||||
{
|
||||
if ( HasSupportAnalyzer(analyzer->GetTag(), analyzer->IsOrig()) )
|
||||
|
|
|
@ -277,6 +277,10 @@ protected:
|
|||
void AppendNewChildren();
|
||||
|
||||
private:
|
||||
// Internal method to eventually delete a child analyzer that's
|
||||
// already Done().
|
||||
void DeleteChild(analyzer_list::iterator i);
|
||||
|
||||
AnalyzerTag::Tag tag;
|
||||
AnalyzerID id;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue