summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-memory.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-03-31 04:01:00 +0000
committerHavoc Pennington <hp@redhat.com>2003-03-31 04:01:00 +0000
commitbc86794f23fa538a405813fb61b531c2eacc9ae1 (patch)
tree42f040afce0d63d312d6f43bf5f6f9bb014c586a /dbus/dbus-memory.c
parentd361874ef6a94a61fa3e0534d8352392edf9bbb9 (diff)
2003-03-30 Havoc Pennington <hp@pobox.com>
* bus/config-parser.c: hacking * dbus/dbus-memory.c: don't use DBusList for the list of stuff to shut down, since it could cause weirdness with the DBusList lock * dbus/dbus-list.c (_dbus_list_test): add tests for the link-oriented stack routines (alloc_link): free the mempool if the first alloc from it fails * dbus/dbus-mempool.c (struct DBusMemBlock): fix alignment issue * dbus/dbus-string.c (UNICODE_VALID): sync new version of this from GLib (_dbus_string_skip_white): new * doc/config-file.txt (Elements): add <includedir>
Diffstat (limited to 'dbus/dbus-memory.c')
-rw-r--r--dbus/dbus-memory.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c
index fbda7139..8efbec59 100644
--- a/dbus/dbus-memory.c
+++ b/dbus/dbus-memory.c
@@ -633,13 +633,17 @@ dbus_free_string_array (char **str_array)
*/
int _dbus_current_generation = 1;
-static DBusList *registered_globals = NULL;
+typedef struct ShutdownClosure ShutdownClosure;
-typedef struct
+struct ShutdownClosure
{
+ ShutdownClosure *next;
DBusShutdownFunction func;
void *data;
-} ShutdownClosure;
+};
+
+_DBUS_DEFINE_GLOBAL_LOCK (shutdown_funcs);
+static ShutdownClosure *registered_globals = NULL;
/**
* The D-BUS library keeps some internal global variables, for example
@@ -656,22 +660,18 @@ typedef struct
void
dbus_shutdown (void)
{
- DBusList *link;
-
- link = _dbus_list_get_first_link (&registered_globals);
- while (link != NULL)
+ while (registered_globals != NULL)
{
- ShutdownClosure *c = link->data;
+ ShutdownClosure *c;
+ c = registered_globals;
+ registered_globals = c->next;
+
(* c->func) (c->data);
-
- dbus_free (c);
- link = _dbus_list_get_next_link (&registered_globals, link);
+ dbus_free (c);
}
- _dbus_list_clear (&registered_globals);
-
_dbus_current_generation += 1;
}
@@ -693,20 +693,17 @@ _dbus_register_shutdown_func (DBusShutdownFunction func,
if (c == NULL)
return FALSE;
-
+
c->func = func;
c->data = data;
- /* We prepend, then shutdown the list in order, so
- * we shutdown last-registered stuff first which
- * is right.
- */
- if (!_dbus_list_prepend (&registered_globals, c))
- {
- dbus_free (c);
- return FALSE;
- }
+ _DBUS_LOCK (shutdown_funcs);
+
+ c->next = registered_globals;
+ registered_globals = c;
+ _DBUS_UNLOCK (shutdown_funcs);
+
return TRUE;
}