add Terminate to input framework to prevent potential shutdown race-conditions.

This commit is contained in:
Bernhard Amann 2013-06-09 08:27:08 -04:00
parent a32bb59770
commit 3517c0ba99
3 changed files with 22 additions and 0 deletions

View file

@ -1289,6 +1289,7 @@ void Manager::SendEndOfData(ReaderFrontend* reader)
SendEndOfData(i);
}
void Manager::SendEndOfData(const Stream *i)
{
#ifdef DEBUG
@ -2174,3 +2175,18 @@ Manager::Stream* Manager::FindStream(ReaderFrontend* reader)
return 0;
}
// function is called on Bro shutdown.
// sinal all frontends that they will cease operation.
void Manager::Terminate()
{
for (map<ReaderFrontend*, Stream*>::iterator i = readers.begin(); i != readers.end(); ++i )
{
if ( i->second->removed )
continue;
i->second->removed = true;
i->second->reader->Stop();
}
}

View file

@ -79,6 +79,11 @@ public:
*/
bool RemoveStream(const string &id);
/**
* Signals the manager to shutdown at Bro's termination.
*/
void Terminate();
protected:
friend class ReaderFrontend;
friend class PutMessage;

View file

@ -357,6 +357,7 @@ void terminate_bro()
file_mgr->Terminate();
log_mgr->Terminate();
input_mgr->Terminate();
thread_mgr->Terminate();
mgr.Drain();