summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-bus.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-04-07 02:01:53 +0000
committerHavoc Pennington <hp@redhat.com>2003-04-07 02:01:53 +0000
commita7f69a41d5b82eb00da20b661181b490039bb70f (patch)
tree0f00e5c4b57ec22fba047c2a654604e4c86a4693 /dbus/dbus-bus.c
parent98572905e60cac7ea971aa0830e2a629bfff208d (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/dbus-bus.c')
-rw-r--r--dbus/dbus-bus.c32
1 files changed, 24 insertions, 8 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;