mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38:20 +00:00
Improving error handling for threads.
If a thread command fails (like the input framework not finding a file), that now (1) no longer hangs Bro, and (2) even allows for propagating error messages back before the thread is stops. (Actually, the thread doesn't really "stop"; the thread manager keeps threads around independent of their success; but it no longer polls them for input.) Closes #858.
This commit is contained in:
parent
ef3b75129f
commit
743fc1680d
3 changed files with 39 additions and 14 deletions
|
@ -80,8 +80,10 @@ double Manager::NextTimestamp(double* network_time)
|
|||
|
||||
for ( msg_thread_list::iterator i = msg_threads.begin(); i != msg_threads.end(); i++ )
|
||||
{
|
||||
if ( (*i)->MightHaveOut() )
|
||||
return timer_mgr->Time();
|
||||
MsgThread* t = *i;
|
||||
|
||||
if ( (*i)->MightHaveOut() && ! t->Killed() )
|
||||
return timer_mgr->Time();
|
||||
}
|
||||
|
||||
return -1.0;
|
||||
|
@ -95,6 +97,12 @@ void Manager::KillThreads()
|
|||
(*i)->Kill();
|
||||
}
|
||||
|
||||
void Manager::KillThread(BasicThread* thread)
|
||||
{
|
||||
DBG_LOG(DBG_THREADING, "Killing thread %s ...", thread->Name());
|
||||
thread->Kill();
|
||||
}
|
||||
|
||||
void Manager::Process()
|
||||
{
|
||||
bool do_beat = false;
|
||||
|
@ -114,7 +122,7 @@ void Manager::Process()
|
|||
if ( do_beat )
|
||||
t->Heartbeat();
|
||||
|
||||
while ( t->HasOut() )
|
||||
while ( t->HasOut() && ! t->Killed() )
|
||||
{
|
||||
Message* msg = t->RetrieveOut();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue