reenable recursive resource_mutex
authorChristian Thaeter <ct@pipapo.org>
Tue, 2 Feb 2010 12:18:13 +0000 (13:18 +0100)
committerChristian Thaeter <ct@pipapo.org>
Tue, 2 Feb 2010 12:18:13 +0000 (13:18 +0100)
this allows nested state transistions

 NOBUG_RESOURCE_WAIT (...)
   {
     lock ();
     NOBUG_RESOURCE_STATE (..) ;
   }

src/nobug_resources.c

index 72fdbe0..58c02f6 100644 (file)
@@ -95,7 +95,10 @@ void
 nobug_resource_init (void)
 {
 #if NOBUG_USE_PTHREAD
-  pthread_mutex_init (&nobug_resource_mutex, NULL);
+  static pthread_mutexattr_t attr;
+  pthread_mutexattr_init (&attr);
+  pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
+  pthread_mutex_init (&nobug_resource_mutex, &attr);
 #endif
 
   llist_init (&nobug_resource_registry);