aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-09-03 14:27:33 +0200
committerMartin Willi <martin@strongswan.org>2009-09-03 14:46:28 +0200
commit12a230ddb4d9396cf551e1c7b5e24bf4eb334d4c (patch)
tree56034d8178017c1105839a85a3b952aca7a95ce1
parenta20e98749aca92ebbdb13f248c31c0dc7c7bc5a6 (diff)
downloadstrongswan-12a230ddb4d9396cf551e1c7b5e24bf4eb334d4c.tar.bz2
strongswan-12a230ddb4d9396cf551e1c7b5e24bf4eb334d4c.tar.xz
Complain about rw(un)lock errors
-rw-r--r--src/libstrongswan/utils/mutex.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/src/libstrongswan/utils/mutex.c b/src/libstrongswan/utils/mutex.c
index 83dde442a..a74a4e47d 100644
--- a/src/libstrongswan/utils/mutex.c
+++ b/src/libstrongswan/utils/mutex.c
@@ -186,10 +186,13 @@ struct private_rwlock_t {
*/
static void lock(private_mutex_t *this)
{
+ int err;
+
profiler_start(&this->profile);
- if (pthread_mutex_lock(&this->mutex))
+ err = pthread_mutex_lock(&this->mutex);
+ if (err)
{
- DBG1("!!!! MUTEX %sLOCK ERROR, your code is buggy !!!", "");
+ DBG1("!!! MUTEX LOCK ERROR: %s !!!", strerror(err));
}
profiler_end(&this->profile);
}
@@ -199,9 +202,12 @@ static void lock(private_mutex_t *this)
*/
static void unlock(private_mutex_t *this)
{
- if (pthread_mutex_unlock(&this->mutex))
+ int err;
+
+ err = pthread_mutex_unlock(&this->mutex);
+ if (err)
{
- DBG1("!!!! MUTEX %sLOCK ERROR, your code is buggy !!!", "UN");
+ DBG1("!!! MUTEX UNLOCK ERROR: %s !!!", strerror(err));
}
}
@@ -445,8 +451,14 @@ condvar_t *condvar_create(condvar_type_t type)
*/
static void read_lock(private_rwlock_t *this)
{
+ int err;
+
profiler_start(&this->profile);
- pthread_rwlock_rdlock(&this->rwlock);
+ err = pthread_rwlock_rdlock(&this->rwlock);
+ if (err != 0)
+ {
+ DBG1("!!! RWLOCK READ LOCK ERROR: %s !!!", strerror(err));
+ }
profiler_end(&this->profile);
}
@@ -455,8 +467,14 @@ static void read_lock(private_rwlock_t *this)
*/
static void write_lock(private_rwlock_t *this)
{
+ int err;
+
profiler_start(&this->profile);
- pthread_rwlock_wrlock(&this->rwlock);
+ err = pthread_rwlock_wrlock(&this->rwlock);
+ if (err != 0)
+ {
+ DBG1("!!! RWLOCK WRITE LOCK ERROR: %s !!!", strerror(err));
+ }
profiler_end(&this->profile);
}
@@ -473,7 +491,13 @@ static bool try_write_lock(private_rwlock_t *this)
*/
static void rw_unlock(private_rwlock_t *this)
{
- pthread_rwlock_unlock(&this->rwlock);
+ int err;
+
+ err = pthread_rwlock_unlock(&this->rwlock);
+ if (err != 0)
+ {
+ DBG1("!!! RWLOCK UNLOCK ERROR: %s !!!", strerror(err));
+ }
}
/**