Commit bf00f0c2 authored by Dan Povey's avatar Dan Povey
Browse files

trunk: minor commit: adding more verbose error messages for mutex problems.

git-svn-id: https://svn.code.sf.net/p/kaldi/code/trunk@4329 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent ca65c55f
......@@ -20,7 +20,7 @@
#include <pthread.h>
#include <cerrno>
#include <string.h>
#include "base/kaldi-error.h"
#include "thread/kaldi-mutex.h"
......@@ -28,20 +28,27 @@ namespace kaldi {
Mutex::Mutex() {
if (pthread_mutex_init(&mutex_, NULL) != 0)
KALDI_ERR << "Cannot initialize pthread mutex";
int ret;
if ((ret = pthread_mutex_init(&mutex_, NULL)) != 0)
KALDI_ERR << "Cannot initialize pthread mutex, error is: "
<< strerror(ret);
}
Mutex::~Mutex() {
if (pthread_mutex_destroy(&mutex_) != 0)
KALDI_ERR << "Cannot destroy pthread mutex";
int ret;
if ( (ret = pthread_mutex_destroy(&mutex_)) != 0) {
KALDI_ERR << "Cannot destroy pthread mutex, error is: "
<< strerror(ret);
}
}
void Mutex::Lock() {
if (pthread_mutex_lock(&mutex_) != 0)
KALDI_ERR << "Error on locking pthread mutex";
int ret;
if ((ret = pthread_mutex_lock(&mutex_)) != 0)
KALDI_ERR << "Error on locking pthread mutex, error is: "
<< strerror(ret);
}
......@@ -51,7 +58,8 @@ bool Mutex::TryLock() {
switch (ret) {
case 0: lock_succeeded = true; break;
case EBUSY: lock_succeeded = false; break;
default: KALDI_ERR << "Error on try-locking pthread mutex";
default: KALDI_ERR << "Error on try-locking pthread mutex, error is: "
<< strerror(ret);
}
return lock_succeeded;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment