fixed deadlock scenarion where g_signal_lookup() would be called with the
authorTim Janik <timj@gtk.org>
Fri, 27 Oct 2000 03:33:31 +0000 (03:33 +0000)
committerTim Janik <timj@src.gnome.org>
Fri, 27 Oct 2000 03:33:31 +0000 (03:33 +0000)
Fri Oct 27 05:35:14 2000  Tim Janik  <timj@gtk.org>

        * gsignal.c (g_signal_newv): fixed deadlock scenarion where
        g_signal_lookup() would be called with the signal lock being
        held. reported by james henstridge.

        * gclosure.c (g_closure_set_meta_marshal): fixed memcpy/overwrite bug
        reported by owen.

gobject/ChangeLog
gobject/gclosure.c
gobject/gsignal.c

index 0c7d401..4cd22d6 100644 (file)
@@ -1,3 +1,12 @@
+Fri Oct 27 05:35:14 2000  Tim Janik  <timj@gtk.org>
+
+       * gsignal.c (g_signal_newv): fixed deadlock scenarion where
+       g_signal_lookup() would be called with the signal lock being
+       held. reported by james henstridge.
+
+       * gclosure.c (g_closure_set_meta_marshal): fixed memcpy/overwrite bug
+       reported by owen.
+
 2000-10-26  Tor Lillqvist  <tml@iki.fi>
 
        * gbsearcharray.c (bsearch_array_insert): Fix gccisms (pointer
index 31cdca6..2dab136 100644 (file)
@@ -161,16 +161,16 @@ g_closure_set_meta_marshal (GClosure       *closure,
   n = CLOSURE_N_NOTIFIERS (closure);
   notifiers = closure->notifiers;
   closure->notifiers = g_renew (GClosureNotifyData, NULL, CLOSURE_N_NOTIFIERS (closure) + 1);
-  closure->notifiers[0].data = marshal_data;
-  closure->notifiers[0].notify = (GClosureNotify) meta_marshal;
   if (notifiers)
     {
       /* usually the meta marshal will be setup right after creation, so the
-       * memcpy() should be rare-case scenario
+       * g_memmove() should be rare-case scenario
        */
-      memcpy (closure->notifiers + 1, notifiers, CLOSURE_N_NOTIFIERS (closure) * sizeof (notifiers[0]));
+      g_memmove (closure->notifiers + 1, notifiers, CLOSURE_N_NOTIFIERS (closure) * sizeof (notifiers[0]));
       g_free (notifiers);
     }
+  closure->notifiers[0].data = marshal_data;
+  closure->notifiers[0].notify = (GClosureNotify) meta_marshal;
   closure->meta_marshal = 1;
 }
 
index 5006ebf..5beb947 100644 (file)
@@ -209,14 +209,23 @@ static inline guint
 signal_id_lookup (GQuark quark,
                  GType  itype)
 {
-  SignalKey key, *signal_key;
-  
-  key.itype = itype;
-  key.quark = quark;
-  
-  signal_key = g_bsearch_array_lookup (&g_signal_key_bsa, &key);
+  do
+    {
+      SignalKey key, *signal_key;
+      
+      key.itype = itype;
+      key.quark = quark;
+      
+      signal_key = g_bsearch_array_lookup (&g_signal_key_bsa, &key);
+      
+      if (signal_key)
+       return signal_key->signal_id;
+      
+      itype = g_type_parent (itype);
+    }
+  while (itype);
   
-  return signal_key ? signal_key->signal_id : 0;
+  return 0;
 }
 
 static gint
@@ -601,27 +610,16 @@ guint
 g_signal_lookup (const gchar *name,
                  GType        itype)
 {
-  GQuark quark;
-
+  guint signal_id;
+  
   g_return_val_if_fail (name != NULL, 0);
   g_return_val_if_fail (G_TYPE_IS_INSTANTIATABLE (itype) || G_TYPE_IS_INTERFACE (itype), 0);
   
   G_LOCK (g_signal_mutex);
-  quark = g_quark_try_string (name);
-  if (quark)
-    do
-      {
-       guint signal_id = signal_id_lookup (quark, itype);
-
-       if (signal_id)
-         return signal_id;
-
-       itype = g_type_parent (itype);
-      }
-    while (itype);
+  signal_id = signal_id_lookup (g_quark_try_string (name), itype);
   G_UNLOCK (g_signal_mutex);
   
-  return 0;
+  return signal_id;
 }
 
 gchar*
@@ -690,7 +688,7 @@ g_signal_newv (const gchar       *signal_name,
   
   G_LOCK (g_signal_mutex);
   
-  signal_id = g_signal_lookup (name, itype);
+  signal_id = signal_id_lookup (g_quark_try_string (name), itype);
   node = LOOKUP_SIGNAL_NODE (signal_id);
   if (node && !node->destroyed)
     {