dbus/dbus dbus-sysdeps-pthread.c,1.5,1.5.2.1

Thiago J. Macieira thiago at kemper.freedesktop.org
Wed Nov 22 09:49:59 PST 2006


Update of /cvs/dbus/dbus/dbus
In directory kemper:/tmp/cvs-serv4728/dbus

Modified Files:
      Tag: DBUS_1_0
	dbus-sysdeps-pthread.c 
Log Message:
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.


Index: dbus-sysdeps-pthread.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps-pthread.c,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -u -d -r1.5 -r1.5.2.1
--- dbus-sysdeps-pthread.c	28 Oct 2006 01:41:37 -0000	1.5
+++ dbus-sysdeps-pthread.c	22 Nov 2006 17:49:57 -0000	1.5.2.1
@@ -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