diff options
author | Havoc Pennington <hp@redhat.com> | 2003-04-07 02:01:53 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-04-07 02:01:53 +0000 |
commit | a7f69a41d5b82eb00da20b661181b490039bb70f (patch) | |
tree | 0f00e5c4b57ec22fba047c2a654604e4c86a4693 /dbus | |
parent | 98572905e60cac7ea971aa0830e2a629bfff208d (diff) |
2003-04-06 Havoc Pennington <hp@pobox.com>
* qt/Makefile.am (dbusinclude_HEADERS): install dbus-qt.h,
from Colin Walters
* configure.in: fixes to Qt detection from Colin Walters
* doc/Makefile.am: Only remove generated docbook dirs if they
exist, from Colin Walters
* dbus/dbus-bus.c: change how we set well-known connections to
NULL, so that it works if a single connection is stored in
two well-known array slots.
* test/Makefile.am: remove a lot of stuff that isn't immediately
useful, it's in CVS history if we want it.
* test/test-service.c: use dbus-mainloop instead of that
watch.[hc] crack
Diffstat (limited to 'dbus')
-rw-r--r-- | dbus/dbus-bus.c | 32 | ||||
-rw-r--r-- | dbus/dbus-threads.c | 3 |
2 files changed, 25 insertions, 10 deletions
diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index df883f51..c16ceeb4 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -50,9 +50,10 @@ */ typedef struct { + DBusConnection *connection; /**< Connection we're associated with */ char *base_service; /**< Base service name of this connection */ - DBusConnection **connection; /**< Pointer to bus_connections entry */ + unsigned int is_well_known : 1; /**< Is one of the well-known connections in our global array */ } BusData; /** The slot we have reserved to store BusData @@ -120,10 +121,14 @@ init_connections_unlocked (void) if (!initialized) { const char *s; - - bus_connections[0] = NULL; - bus_connections[1] = NULL; - bus_connections[2] = NULL; + int i; + + i = 0; + while (i < N_BUS_TYPES) + { + bus_connections[i] = NULL; + ++i; + } /* Don't init these twice, we may run this code twice if * init_connections_unlocked() fails midway through. @@ -238,10 +243,19 @@ bus_data_free (void *data) { BusData *bd = data; - if (bd->connection) + if (bd->is_well_known) { + int i; _DBUS_LOCK (bus); - *bd->connection = NULL; + /* We may be stored in more than one slot */ + i = 0; + while (i < N_BUS_TYPES) + { + if (bus_connections[i] == bd->connection) + bus_connections[i] = NULL; + + ++i; + } _DBUS_UNLOCK (bus); } @@ -268,6 +282,8 @@ ensure_bus_data (DBusConnection *connection) data_slot_unref (); return NULL; } + + bd->connection = connection; if (!dbus_connection_set_data (connection, bus_data_slot, bd, bus_data_free)) @@ -385,7 +401,7 @@ dbus_bus_get (DBusBusType type, bd = ensure_bus_data (connection); _dbus_assert (bd != NULL); - bd->connection = &bus_connections[type]; + bd->is_well_known = TRUE; _DBUS_UNLOCK (bus); return connection; diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index e8b9f3cd..a573a1ec 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -350,6 +350,7 @@ dbus_threads_init (const DBusThreadFunctions *functions) return TRUE; } +/** @} */ #ifdef DBUS_BUILD_TESTS /** Fake mutex used for debugging */ @@ -489,5 +490,3 @@ _dbus_threads_init_debug (void) } #endif /* DBUS_BUILD_TESTS */ - -/** @} */ |