make pthread_mutex_unlock include the reason for why the unlock fails.

This commit is contained in:
Bernhard Amann 2012-07-11 20:10:49 -07:00
parent b31ef8cde5
commit 8ff8c66655

View file

@ -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;