1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
diff --git b/avahi-client/client.c a/avahi-client/client.c
index 2b29480..6435723 100644
--- b/avahi-client/client.c
+++ a/avahi-client/client.c
@@ -141,10 +141,9 @@ static DBusHandlerResult filter_func(DBusConnection *bus, DBusMessage *message,
if (strcmp(name, AVAHI_DBUS_NAME) == 0) {
- if (old[0] &&
- avahi_client_is_connected(client)) {
+ if (avahi_client_is_connected(client)) {
- /* Regardless if the server lost its name or
+ /* Regardless if the server lost or acquired its name or
* if the name was transfered: our services are no longer
* available, so we disconnect ourselves */
avahi_client_set_errno(client, AVAHI_ERR_DISCONNECTED);
@@ -523,7 +522,7 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
goto fail;
}
- if (!dbus_connection_add_filter(client->bus, filter_func, client, NULL)) {
+ if (!dbus_connection_add_filter (client->bus, filter_func, client, NULL)) {
if (ret_error)
*ret_error = AVAHI_ERR_NO_MEMORY;
goto fail;
@@ -560,7 +559,9 @@ AvahiClient *avahi_client_new(const AvahiPoll *poll_api, AvahiClientFlags flags,
if (dbus_error_is_set(&error))
goto fail;
- if (!dbus_bus_start_service_by_name(client->bus, AVAHI_DBUS_NAME, 0, NULL, &error)) {
+
+ if (!(dbus_bus_name_has_owner(client->bus, AVAHI_DBUS_NAME, &error)) ||
+ dbus_error_is_set(&error)) {
/* We free the error so its not set, that way the fail target
* will return the NO_DAEMON error rather than a DBUS error */
|