mirror of
https://github.com/zeek/zeek.git
synced 2025-10-17 14:08:20 +00:00
Merge remote-tracking branch 'origin/topic/robin/log-threads' into topic/bernhard/input-threads
Conflicts: src/threading/Manager.cc
This commit is contained in:
commit
b34a0b6deb
16 changed files with 320 additions and 117 deletions
|
@ -20,8 +20,8 @@ BasicThread::BasicThread()
|
|||
terminating = false;
|
||||
pthread = 0;
|
||||
|
||||
buf = 0;
|
||||
buf_len = 1024;
|
||||
buf_len = 2048;
|
||||
buf = (char*) malloc(buf_len);
|
||||
|
||||
name = Fmt("thread-%d", ++thread_counter);
|
||||
|
||||
|
@ -57,9 +57,6 @@ void BasicThread::SetOSName(const string& name)
|
|||
|
||||
const char* BasicThread::Fmt(const char* format, ...)
|
||||
{
|
||||
if ( ! buf )
|
||||
buf = (char*) malloc(buf_len);
|
||||
|
||||
va_list al;
|
||||
va_start(al, format);
|
||||
int n = safe_vsnprintf(buf, buf_len, format, al);
|
||||
|
@ -67,13 +64,15 @@ const char* BasicThread::Fmt(const char* format, ...)
|
|||
|
||||
if ( (unsigned int) n >= buf_len )
|
||||
{ // Not enough room, grow the buffer.
|
||||
buf_len = n + 32;
|
||||
buf = (char*) realloc(buf, buf_len);
|
||||
int tmp_len = n + 32;
|
||||
char* tmp = (char*) malloc(tmp_len);
|
||||
|
||||
// Is it portable to restart?
|
||||
va_start(al, format);
|
||||
n = safe_vsnprintf(buf, buf_len, format, al);
|
||||
n = safe_vsnprintf(tmp, tmp_len, format, al);
|
||||
va_end(al);
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
return buf;
|
||||
|
|
|
@ -102,25 +102,25 @@ void Manager::Process()
|
|||
next_beat = 0;
|
||||
}
|
||||
|
||||
if ( ! t->HasOut() )
|
||||
continue;
|
||||
|
||||
Message* msg = t->RetrieveOut();
|
||||
|
||||
if ( msg->Process() )
|
||||
while ( t->HasOut() )
|
||||
{
|
||||
//if ( network_time ) //&& network_time ) // FIXME: ask robin again if he needs this. makes input interface not work in bro_init.
|
||||
Message* msg = t->RetrieveOut();
|
||||
|
||||
did_process = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
string s = msg->Name() + " failed, terminating thread " + t->Name() + " (in ThreadManager)";
|
||||
reporter->Error("%s", s.c_str());
|
||||
t->Stop();
|
||||
if ( msg->Process() )
|
||||
{
|
||||
//if ( network_time ) // FIXME: ask robin again if he needs this. makes input interface not work in bro_init.
|
||||
did_process = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
string s = msg->Name() + " failed, terminating thread";
|
||||
reporter->Error("%s", s.c_str());
|
||||
t->Stop();
|
||||
}
|
||||
|
||||
delete msg;
|
||||
delete msg;
|
||||
}
|
||||
}
|
||||
|
||||
// fprintf(stderr, "P %.6f %.6f do_beat=%d did_process=%d next_next=%.6f\n", network_time, timer_mgr->Time(), do_beat, (int)did_process, next_beat);
|
||||
|
|
|
@ -281,7 +281,7 @@ void MsgThread::GetStats(Stats* stats)
|
|||
{
|
||||
stats->sent_in = cnt_sent_in;
|
||||
stats->sent_out = cnt_sent_out;
|
||||
stats->pending_in = cnt_sent_in - queue_in.Size();
|
||||
stats->pending_out = cnt_sent_out - queue_out.Size();
|
||||
stats->pending_in = queue_in.Size();
|
||||
stats->pending_out = queue_out.Size();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue