locking around source_funcs->finalize
- From: Tim Janik <timj imendio com>
- To: Owen Taylor <otaylor redhat com>
- Cc: Gtk+ Developers <gtk-devel-list gnome org>
- Subject: locking around source_funcs->finalize
- Date: Fri, 2 Jun 2006 18:59:13 +0200 (CEST)
hi Owen.
reading up on g_source_unref() again, i notice that the
GMainContext lock is removed and re-acquired around
callback_funcs->unref(), but not around source_funcs->finalize();
supposing you're unlocking around unref() so that the
handler may do things like adding a new idle handler
to the context, shouldnt the same semantics be provided
for source_funcs->finalize() as well?
static void
g_source_unref_internal (GSource *source,
GMainContext *context,
gboolean have_lock)
{
gpointer old_cb_data = NULL;
GSourceCallbackFuncs *old_cb_funcs = NULL;
g_return_if_fail (source != NULL);
if (!have_lock && context)
LOCK_CONTEXT (context);
source->ref_count--;
if (source->ref_count == 0)
{
old_cb_data = source->callback_data;
old_cb_funcs = source->callback_funcs;
source->callback_data = NULL;
source->callback_funcs = NULL;
if (context && !SOURCE_DESTROYED (source))
{
g_warning (G_STRLOC ": ref_count == 0, but source is still attached to a context!");
source->ref_count++;
}
else if (context)
g_source_list_remove (source, context);
if (source->source_funcs->finalize)
source->source_funcs->finalize (source);
lock is being held if have_lock || context.
g_slist_free (source->poll_fds);
source->poll_fds = NULL;
g_free (source);
}
if (!have_lock && context)
UNLOCK_CONTEXT (context);
if (old_cb_funcs)
{
if (have_lock)
UNLOCK_CONTEXT (context);
old_cb_funcs->unref (old_cb_data);
no lock is being held.
if (have_lock)
LOCK_CONTEXT (context);
}
}
---
ciaoTJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]