dbus/dbus dbus-sysdeps-pthread.c,1.5,1.6
Thiago J. Macieira
thiago at kemper.freedesktop.org
Sun Nov 19 10:23:29 PST 2006
Update of /cvs/dbus/dbus/dbus
In directory kemper:/tmp/cvs-serv10781/dbus
Modified Files:
dbus-sysdeps-pthread.c
Log Message:
* 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.
Index: dbus-sysdeps-pthread.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-pthread.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbus-sysdeps-pthread.c 28 Oct 2006 01:41:37 -0000 1.5
+++ dbus-sysdeps-pthread.c 19 Nov 2006 18:23:27 -0000 1.6
@@ -153,6 +153,7 @@
{
/* 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_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_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;
More information about the dbus-commit
mailing list