mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Another small change to MsgThread API.
Threads will now reliably get a call to DoFinish() no matter how the thread terminates. This will always be called from within the thread, whereas the destructor is called from the main thread after the child thread has already terminated. Also removing debugging code. However, two problems remain with the ASCII writer (seeing them only on MacOS): - the #start/#end timestamps contain only dummy values right now. The odd thing is that once I enable strftime() to print actual timestamps, I get crashes (even though strftime() is supposed to be thread-safe). - occassionally, there's still output missing in tests. In those cases, the file descriptor apparently goes bad: a write() will suddently return EBADF for reasons I don't understand yet.
This commit is contained in:
parent
053b307e24
commit
71fc2a1728
6 changed files with 39 additions and 27 deletions
|
@ -35,7 +35,7 @@ BasicThread::BasicThread()
|
|||
|
||||
BasicThread::~BasicThread()
|
||||
{
|
||||
if ( buf )
|
||||
if ( buf )
|
||||
free(buf);
|
||||
|
||||
delete [] name;
|
||||
|
@ -50,6 +50,7 @@ void BasicThread::SetName(const char* arg_name)
|
|||
|
||||
void BasicThread::SetOSName(const char* arg_name)
|
||||
{
|
||||
|
||||
#ifdef HAVE_LINUX
|
||||
prctl(PR_SET_NAME, arg_name, 0, 0, 0);
|
||||
#endif
|
||||
|
@ -131,16 +132,12 @@ void BasicThread::PrepareStop()
|
|||
|
||||
void BasicThread::Stop()
|
||||
{
|
||||
// XX fprintf(stderr, "stop1 %s %d %d\n", name, started, terminating);
|
||||
|
||||
if ( ! started )
|
||||
return;
|
||||
|
||||
if ( terminating )
|
||||
return;
|
||||
|
||||
// XX fprintf(stderr, "stop2 %s\n", name);
|
||||
|
||||
DBG_LOG(DBG_THREADING, "Signaling thread %s to terminate ...", name);
|
||||
|
||||
OnStop();
|
||||
|
@ -177,7 +174,6 @@ void BasicThread::Kill()
|
|||
|
||||
void BasicThread::Done()
|
||||
{
|
||||
// XX fprintf(stderr, "DONE from thread %s\n", name);
|
||||
DBG_LOG(DBG_THREADING, "Thread %s has finished", name);
|
||||
|
||||
terminating = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue