Re: plea for review



Hi Tim,

> i went over gtype.c and inserted the required locks to make it thread safe.
> however, the code is far from simple, there are more than 100 lock/unlock
> calls now.
> that's why i'd like to have it reviewed by as many eyes as possible, intrinsic
> knowledge of the type system isn't strictly neccessary to catch basic locking
> issues, so please take the time and have a look (especially sebastian).

I looked over it (the CVS-version of gtype.c) for the last 3 hours and didn't
find any pitfalls, apart from being a bit unhappy about calling external code
in the middle of write updates. But I agree, bad consequences should be quite
improbable, though not impossible. The only thing that should be changed is to
remove the type_init_lock, as it doesn't seem to have any use here. Patch
attached.

Bye,
Sebastian
-- 
Sebastian Wilhelmi
mailto:wilhelmi ira uka de
http://goethe.ira.uka.de/~wilhelmi
Index: gtype.c
===================================================================
RCS file: /cvs/gnome/glib/gobject/gtype.c,v
retrieving revision 1.18
diff -u -b -B -r1.18 gtype.c
--- gtype.c	2001/02/04 07:03:52	1.18
+++ gtype.c	2001/02/06 15:33:24
@@ -2365,21 +2365,17 @@
 void
 g_type_init (GTypeDebugFlags debug_flags)
 {
-  G_LOCK_DEFINE_STATIC (type_init_lock);
   static TypeNode *type0_node = NULL;
   gchar *env_string;
   GTypeInfo info;
   TypeNode *node;
   GType type;
   
-  G_LOCK (type_init_lock);
-  
   G_WRITE_LOCK (&type_rw_lock);
   
   if (static_last_fundamental_id)
     {
       G_WRITE_UNLOCK (&type_rw_lock);
-      G_UNLOCK (type_init_lock);
       return;
     }
 
@@ -2460,6 +2456,4 @@
   /* Signal system
    */
   g_signal_init ();
-  
-  G_UNLOCK (type_init_lock);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]