-- more assert fixes for thrift concurrency
Reviewed By: mcslee
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665074 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/concurrency/Monitor.cpp b/lib/cpp/src/concurrency/Monitor.cpp
index 955fe9a..2443a6e 100644
--- a/lib/cpp/src/concurrency/Monitor.cpp
+++ b/lib/cpp/src/concurrency/Monitor.cpp
@@ -33,10 +33,10 @@
try {
int ret = pthread_mutex_init(&pthread_mutex_, NULL);
- assert(ret);
+ assert(ret == 0);
mutexInitialized_ = true;
ret = pthread_cond_init(&pthread_cond_, NULL);
- assert(ret);
+ assert(ret == 0);
condInitialized_ = true;
} catch(...) {
cleanup();
@@ -52,11 +52,10 @@
void wait(long long timeout) const {
// XXX Need to assert that caller owns mutex
- bool bret = (timeout >= 0LL);
- assert(bret);
+ assert(timeout >= 0LL);
if (timeout == 0LL) {
int iret = pthread_cond_wait(&pthread_cond_, &pthread_mutex_);
- assert(iret);
+ assert(iret == 0);
} else {
struct timespec abstime;
long long now = Util::currentTime();
@@ -65,8 +64,7 @@
&pthread_mutex_,
&abstime);
if (result == ETIMEDOUT) {
- bret = (Util::currentTime() >= (now + timeout));
- assert(bret);
+ assert(Util::currentTime() >= (now + timeout));
}
}
}
@@ -74,13 +72,13 @@
void notify() {
// XXX Need to assert that caller owns mutex
int iret = pthread_cond_signal(&pthread_cond_);
- assert(iret);
+ assert(iret == 0);
}
void notifyAll() {
// XXX Need to assert that caller owns mutex
int iret = pthread_cond_broadcast(&pthread_cond_);
- assert(iret);
+ assert(iret == 0);
}
private:
@@ -89,13 +87,13 @@
if (mutexInitialized_) {
mutexInitialized_ = false;
int iret = pthread_mutex_destroy(&pthread_mutex_);
- assert(iret);
+ assert(iret == 0);
}
if (condInitialized_) {
condInitialized_ = false;
int iret = pthread_cond_destroy(&pthread_cond_);
- assert(iret);
+ assert(iret == 0);
}
}