From 8a572c0da1be99527c52f620dc7fd04eb0775bde Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Fri, 27 Oct 2000 03:33:31 +0000 Subject: [PATCH] fixed deadlock scenarion where g_signal_lookup() would be called with the Fri Oct 27 05:35:14 2000 Tim Janik * 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 | 9 +++++++++ gobject/gclosure.c | 8 ++++---- gobject/gsignal.c | 44 +++++++++++++++++++++----------------------- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 0c7d401..4cd22d6 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,12 @@ +Fri Oct 27 05:35:14 2000 Tim Janik + + * 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 * gbsearcharray.c (bsearch_array_insert): Fix gccisms (pointer diff --git a/gobject/gclosure.c b/gobject/gclosure.c index 31cdca6..2dab136 100644 --- a/gobject/gclosure.c +++ b/gobject/gclosure.c @@ -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; } diff --git a/gobject/gsignal.c b/gobject/gsignal.c index 5006ebf..5beb947 100644 --- a/gobject/gsignal.c +++ b/gobject/gsignal.c @@ -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) { -- 2.7.4