summaryrefslogtreecommitdiffstats
path: root/avahi-client/client.c
diff options
context:
space:
mode:
authorTrent Lloyd <lathiat@bur.st>2005-08-23 21:50:39 +0000
committerTrent Lloyd <lathiat@bur.st>2005-08-23 21:50:39 +0000
commitbb421d3a4e8e9bbf99c340f5559e6fd76dac5196 (patch)
tree2208fdc99af3fe4f6049e1a2a0fb48d8925eb54d /avahi-client/client.c
parent788c921143004a2fdbf3abcba1a59f1693e2e07d (diff)
* avahi-client/
- Create a new function avahi_dbus_bus_get which acts like dbus_bus_get but instead gets a private connection, this solves the bug where you can't have more than one AvahiClient at once because each successive AvahiClient stepped on the DBusWatch handling of the previous due to libdbus liking to recycle its connections. Introduced a new configure option --with-dbus-system-address= if you set this, you likely want it set to unix:path=/some/socket/here The default is /var/run/dbus/system_socket_address, because this path is hard coded into D-BUS itself, and the DBUS_SYSTEM_BUS_ADDRESS environment variable is now supported to change this at runtime which is inline with libdbus. git-svn-id: file:///home/lennart/svn/public/avahi/trunk@432 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-client/client.c')
-rw-r--r--avahi-client/client.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/avahi-client/client.c b/avahi-client/client.c
index bb623c0..27f7462 100644
--- a/avahi-client/client.c
+++ b/avahi-client/client.c
@@ -232,6 +232,43 @@ fail:
return e;
}
+/* This function acts like dbus_bus_get but creates a private
+ * connection instead */
+static DBusConnection*
+avahi_dbus_bus_get (DBusBusType type, DBusError *error)
+{
+ DBusConnection *conn;
+ char *env_addr;
+
+ env_addr = getenv ("DBUS_SYSTEM_BUS_ADDRESS");
+
+ if (env_addr == NULL || (strcmp (env_addr, "") == 0))
+ {
+ env_addr = DBUS_SYSTEM_BUS_DEFAULT_ADDRESS;
+ }
+
+ conn = dbus_connection_open_private (env_addr, error);
+
+ if (!conn)
+ {
+ printf ("Failed to open private connection: %s\n", error->message);
+ return NULL;
+ }
+
+ dbus_connection_set_exit_on_disconnect (conn, TRUE);
+
+ if (!dbus_bus_register (conn, error))
+ {
+ printf ("Failed to register connection\n");
+ dbus_connection_close (conn);
+ dbus_connection_unref (conn);
+
+ return NULL;
+ }
+
+ return conn;
+}
+
AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientCallback callback, void *userdata, int *ret_error) {
AvahiClient *client = NULL;
DBusError error;
@@ -261,7 +298,7 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientCallback cal
AVAHI_LLIST_HEAD_INIT(AvahiServiceTypeBrowser, client->service_type_browsers);
AVAHI_LLIST_HEAD_INIT(AvahiServiceResolver, client->service_resolvers);
- if (!(client->bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error)) ||
+ if (!(client->bus = avahi_dbus_bus_get(DBUS_BUS_SYSTEM, &error)) ||
dbus_error_is_set (&error))
goto fail;