mirror of git://git.sysmocom.de/ofono
gdbus: Don't refresh objects/props if disconnected
If g_dbus_client_set_proxy_handlers gets called from within a proxy_removed callback, the code may end up refreshing the proxy's properties and incorrectly access the client's proxy_list as it gets freed. This patch fixes this, so that get_managed_objects does nothing if it gets called during a service disconnect.
This commit is contained in:
parent
d6bc91ebfc
commit
8660527b11
|
@ -1107,6 +1107,9 @@ static void get_managed_objects(GDBusClient *client)
|
||||||
{
|
{
|
||||||
DBusMessage *msg;
|
DBusMessage *msg;
|
||||||
|
|
||||||
|
if (!client->connected)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!client->proxy_added && !client->proxy_removed) {
|
if (!client->proxy_added && !client->proxy_removed) {
|
||||||
refresh_properties(client);
|
refresh_properties(client);
|
||||||
return;
|
return;
|
||||||
|
@ -1142,13 +1145,13 @@ static void service_connect(DBusConnection *conn, void *user_data)
|
||||||
|
|
||||||
g_dbus_client_ref(client);
|
g_dbus_client_ref(client);
|
||||||
|
|
||||||
|
client->connected = TRUE;
|
||||||
|
|
||||||
if (client->connect_func)
|
if (client->connect_func)
|
||||||
client->connect_func(conn, client->connect_data);
|
client->connect_func(conn, client->connect_data);
|
||||||
|
|
||||||
get_managed_objects(client);
|
get_managed_objects(client);
|
||||||
|
|
||||||
client->connected = TRUE;
|
|
||||||
|
|
||||||
g_dbus_client_unref(client);
|
g_dbus_client_unref(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,13 +1159,13 @@ static void service_disconnect(DBusConnection *conn, void *user_data)
|
||||||
{
|
{
|
||||||
GDBusClient *client = user_data;
|
GDBusClient *client = user_data;
|
||||||
|
|
||||||
|
client->connected = FALSE;
|
||||||
|
|
||||||
g_list_free_full(client->proxy_list, proxy_free);
|
g_list_free_full(client->proxy_list, proxy_free);
|
||||||
client->proxy_list = NULL;
|
client->proxy_list = NULL;
|
||||||
|
|
||||||
if (client->disconn_func) {
|
if (client->disconn_func)
|
||||||
client->disconn_func(conn, client->disconn_data);
|
client->disconn_func(conn, client->disconn_data);
|
||||||
client->connected = FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBusHandlerResult message_filter(DBusConnection *connection,
|
static DBusHandlerResult message_filter(DBusConnection *connection,
|
||||||
|
|
Loading…
Reference in New Issue