From: Lennart Poettering Date: Fri, 20 Jan 2006 21:20:42 +0000 (+0000) Subject: small fix that speeds up destruction of AvahiClient objects. We will now simply termi... X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=1463c6f70a4755ddbf447c00aacb78c66852424e;p=catta small fix that speeds up destruction of AvahiClient objects. We will now simply terminate the DBUS connection before freeing local objects. This way the number of server calls is decreased. The server will clean up the client objects anyway if the connection is closed, hence there is no need to do that manually from the client side. git-svn-id: file:///home/lennart/svn/public/avahi/trunk@1090 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-client/client.c b/avahi-client/client.c index 2f9b870..4ee8e41 100644 --- a/avahi-client/client.c +++ b/avahi-client/client.c @@ -595,6 +595,11 @@ fail: void avahi_client_free(AvahiClient *client) { assert(client); + if (client->bus) + /* Disconnect in advance, so that the free() functions won't + * issue needless server calls */ + dbus_connection_disconnect(client->bus); + while (client->groups) avahi_entry_group_free(client->groups); @@ -619,10 +624,8 @@ void avahi_client_free(AvahiClient *client) { while (client->record_browsers) avahi_record_browser_free(client->record_browsers); - if (client->bus) { - dbus_connection_disconnect(client->bus); + if (client->bus) dbus_connection_unref(client->bus); - } avahi_free(client->version_string); avahi_free(client->host_name); @@ -859,5 +862,7 @@ fail: int avahi_client_is_connected(AvahiClient *client) { assert(client); - return client->state == AVAHI_CLIENT_S_RUNNING || client->state == AVAHI_CLIENT_S_REGISTERING || client->state == AVAHI_CLIENT_S_COLLISION; + return + dbus_connection_get_is_connected(client->bus) && + (client->state == AVAHI_CLIENT_S_RUNNING || client->state == AVAHI_CLIENT_S_REGISTERING || client->state == AVAHI_CLIENT_S_COLLISION); }