mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 16:48:19 +00:00
make pthread_mutex_unlock include the reason for why the unlock fails.
This commit is contained in:
parent
b31ef8cde5
commit
8ff8c66655
1 changed files with 5 additions and 4 deletions
|
@ -86,12 +86,12 @@ void BasicThread::Start()
|
||||||
|
|
||||||
int err = pthread_mutex_init(&terminate, 0);
|
int err = pthread_mutex_init(&terminate, 0);
|
||||||
if ( err != 0 )
|
if ( err != 0 )
|
||||||
reporter->FatalError("Cannot create terminate mutex for thread %s:%s", name.c_str(), strerror(err));
|
reporter->FatalError("Cannot create terminate mutex for thread %s: %s", name.c_str(), strerror(err));
|
||||||
|
|
||||||
// We use this like a binary semaphore and acquire it immediately.
|
// We use this like a binary semaphore and acquire it immediately.
|
||||||
err = pthread_mutex_lock(&terminate);
|
err = pthread_mutex_lock(&terminate);
|
||||||
if ( err != 0 )
|
if ( err != 0 )
|
||||||
reporter->FatalError("Cannot aquire terminate mutex for thread %s:%s", name.c_str(), strerror(err));
|
reporter->FatalError("Cannot aquire terminate mutex for thread %s: %s", name.c_str(), strerror(err));
|
||||||
|
|
||||||
err = pthread_create(&pthread, 0, BasicThread::launcher, this);
|
err = pthread_create(&pthread, 0, BasicThread::launcher, this);
|
||||||
if ( err != 0 )
|
if ( err != 0 )
|
||||||
|
@ -116,8 +116,9 @@ void BasicThread::Stop()
|
||||||
|
|
||||||
// Signal that it's ok for the thread to exit now by unlocking the
|
// Signal that it's ok for the thread to exit now by unlocking the
|
||||||
// mutex.
|
// mutex.
|
||||||
if ( pthread_mutex_unlock(&terminate) != 0 )
|
int err = pthread_mutex_unlock(&terminate);
|
||||||
reporter->FatalError("Failure flagging terminate condition for thread %s", name.c_str());
|
if ( err != 0 )
|
||||||
|
reporter->FatalError("Failure flagging terminate condition for thread %s: %s", name.c_str(), strerror(err));
|
||||||
|
|
||||||
terminating = true;
|
terminating = true;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue