summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Macieira <thiago@kde.org>2006-11-22 17:49:57 +0000
committerThiago Macieira <thiago@kde.org>2006-11-22 17:49:57 +0000
commit9464d1c17d963dd4f6f8fc2021bcce11a9a4ce30 (patch)
tree3a7b92899078fa46dcf23818827f93b7a205f793
parent5528d9ee33cbaea391d004aea785ab335b6a45f2 (diff)
downloaddbus-9464d1c17d963dd4f6f8fc2021bcce11a9a4ce30.tar.gz
Backporting from HEAD:
* dbus/dbus-sysdeps-pthread.c (_dbus_pthread_mutex_lock, _dbus_pthread_condvar_wait, _dbus_pthread_condvar_wait_timeout): set pmutex->holder to pthread_self() after coming back from a conditional variable wait as well as in one codepath where it was forgotten. Approved by: Havoc Pennington.
-rw-r--r--ChangeLog9
-rw-r--r--dbus/dbus-sysdeps-pthread.c5
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 031e0ec3..79b68edf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-11-19 Thiago Macieira <thiago@kde.org>
+
+ * dbus/dbus-sysdeps-pthread.c (_dbus_pthread_mutex_lock,
+ _dbus_pthread_condvar_wait,
+ _dbus_pthread_condvar_wait_timeout): set pmutex->holder to
+ pthread_self() after coming back from a conditional variable
+ wait as well as in one codepath where it was forgotten.
+ Approved by: Havoc Pennington.
+
2006-11-17 Havoc Pennington <hp@redhat.com>
* update-dbus-docs.sh: allow setting fd.org username via env
diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c
index 2f33b1c4..55d3ea28 100644
--- a/dbus/dbus-sysdeps-pthread.c
+++ b/dbus/dbus-sysdeps-pthread.c
@@ -153,6 +153,7 @@ _dbus_pthread_mutex_lock (DBusMutex *mutex)
{
/* Wait for the lock */
PTHREAD_CHECK ("pthread_mutex_lock", pthread_mutex_lock (&pmutex->lock));
+ pmutex->holder = self;
_dbus_assert (pmutex->count == 0);
}
@@ -222,10 +223,11 @@ _dbus_pthread_condvar_wait (DBusCondVar *cond,
_dbus_assert (pthread_equal (pmutex->holder, pthread_self ()));
old_count = pmutex->count;
- pmutex->count = 0;
+ pmutex->count = 0; /* allow other threads to lock */
PTHREAD_CHECK ("pthread_cond_wait", pthread_cond_wait (&pcond->cond, &pmutex->lock));
_dbus_assert (pmutex->count == 0);
pmutex->count = old_count;
+ pmutex->holder = pthread_self(); /* other threads may have locked the mutex in the meantime */
}
static dbus_bool_t
@@ -264,6 +266,7 @@ _dbus_pthread_condvar_wait_timeout (DBusCondVar *cond,
_dbus_assert (pmutex->count == 0);
pmutex->count = old_count;
+ pmutex->holder = pthread_self(); /* other threads may have locked the mutex in the meantime */
/* return true if we did not time out */
return result != ETIMEDOUT;