Subject: [PATCH] gdbus: Remove proxies when client disconnects

Remove proxies and generate proxy_removed callbacks even when there are
no corresponding InterfaceRemoved signals.

This patch fixes having zombie gdbus proxy object when a server
disconnects without sending InterfaceRemoved signals. These objects
may interact with new server instances, for example, making
InterfaceAdded signals of new objects with the same name be filtered
out as duplicated, or staying allocated, but unused, if the new server
doesn't reuse the object paths. Note that as a side-effect, the
lifetime of a gdbus proxy becomes stricter: it lives at most for the
duration of a single connection to a single instance of a server
process.
---
gdbus/client.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/gdbus/client.c b/gdbus/client.c
index f700b7e..d80e252 100644
--- a/gdbus/client.c
+++ b/gdbus/client.c
@@ -1153,6 +1153,10 @@ static DBusHandlerResult message_filter(DBusConnection *connection,

if (*new == '\0' && client->unique_name != NULL &&
g_str_equal(old, client->unique_name) == TRUE) {
+
+ g_list_free_full(client->proxy_list, proxy_free);
+ client->proxy_list = NULL;
+
if (client->disconn_func)
client->disconn_func(client->dbus_conn,
client->disconn_data);
--
1.8.2.3



2013-05-28 13:23:53

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] gdbus: Remove proxies when client disconnects

Hi Henrique,

On Mon, May 27, 2013 at 10:15 AM, Henrique Dante de Almeida
<[email protected]> wrote:
> Remove proxies and generate proxy_removed callbacks even when there are
> no corresponding InterfaceRemoved signals.
>
> This patch fixes having zombie gdbus proxy object when a server
> disconnects without sending InterfaceRemoved signals. These objects
> may interact with new server instances, for example, making
> InterfaceAdded signals of new objects with the same name be filtered
> out as duplicated, or staying allocated, but unused, if the new server
> doesn't reuse the object paths. Note that as a side-effect, the
> lifetime of a gdbus proxy becomes stricter: it lives at most for the
> duration of a single connection to a single instance of a server
> process.
> ---
> gdbus/client.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/gdbus/client.c b/gdbus/client.c
> index f700b7e..d80e252 100644
> --- a/gdbus/client.c
> +++ b/gdbus/client.c
> @@ -1153,6 +1153,10 @@ static DBusHandlerResult message_filter(DBusConnection *connection,
>
> if (*new == '\0' && client->unique_name != NULL &&
> g_str_equal(old, client->unique_name) == TRUE) {
> +
> + g_list_free_full(client->proxy_list, proxy_free);
> + client->proxy_list = NULL;
> +
> if (client->disconn_func)
> client->disconn_func(client->dbus_conn,
> client->disconn_data);
> --
> 1.8.2.3

Pushed, thanks.


--
Luiz Augusto von Dentz