Skip to content

Commit

Permalink
Improve file analysis manager shutdown/cleanup.
Browse files Browse the repository at this point in the history
file_analysis::Manager's dtor now doesn't assume any more analysis
progress can be made because too many of Bro's other subsystems
are shutdown by that point.  Any file analysis requests made after
Terminate cannot be reliably processed.
  • Loading branch information
jsiwek committed Apr 29, 2014
1 parent b029d18 commit 4b059ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 21 additions & 1 deletion src/file_analysis/Manager.cc
Expand Up @@ -27,7 +27,22 @@ Manager::Manager()

Manager::~Manager()
{
Terminate();
// Have to assume that too much of Bro has been shutdown by this point
// to do anything more than reclaim memory.

File* f;
bool* b;

IterCookie* it = id_map.InitForIteration();

while ( (f = id_map.NextEntry(it)) )
delete f;

it = ignored.InitForIteration();

while( (b = ignored.NextEntry(it)) )
delete b;

delete magic_state;
}

Expand Down Expand Up @@ -58,10 +73,15 @@ void Manager::Terminate()
HashKey* key;

while ( id_map.NextEntry(key, it) )
{
keys.push_back(static_cast<const char*>(key->Key()));
delete key;
}

for ( size_t i = 0; i < keys.size(); ++i )
Timeout(keys[i], true);

mgr.Drain();
}

string Manager::HashHandle(const string& handle) const
Expand Down
2 changes: 1 addition & 1 deletion src/main.cc
Expand Up @@ -379,10 +379,10 @@ void terminate_bro()
delete secondary_path;
delete remote_serializer;
delete analyzer_mgr;
delete file_mgr;
delete log_mgr;
delete plugin_mgr;
delete thread_mgr;
delete file_mgr;
delete reporter;

reporter = 0;
Expand Down

0 comments on commit 4b059ea

Please sign in to comment.