libnm: don't add objects to cache until they're async-inited

Otherwise the uninitializeded objects could be prematurely signalled if their
paths are seen twice in quick succession. This happens when you have ethernet
hardware and add an ethernet connection -- it's immediatelly added to
AvialableConnections and the property reload signals the object addition
before the NMRemoteSettings's GetSettings() finishes:

  # nmcli c add type ethernet autoconnect no ifname '*'
  (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed
  Connection '(null)' ((null)) successfully added.
  #

https://bugzilla.gnome.org/show_bug.cgi?id=754794
This commit is contained in:
Lubomir Rintel 2015-09-08 19:16:50 +02:00
parent 9a88d72fd4
commit 88f0d646d5

View file

@ -468,6 +468,11 @@ create_async_inited (GObject *object, GAsyncResult *result, gpointer user_data)
}
create_async_complete (object, async_data);
if (_nm_object_cache_get (async_data->path))
g_clear_object (&object);
else
_nm_object_cache_add (NM_OBJECT (object));
}
static void
@ -496,7 +501,6 @@ create_async_got_type (NMObjectTypeAsyncData *async_data, GType type)
NM_OBJECT_PATH, async_data->path,
NM_OBJECT_DBUS_CONNECTION, async_data->connection,
NULL);
_nm_object_cache_add (NM_OBJECT (object));
g_async_initable_init_async (G_ASYNC_INITABLE (object), G_PRIORITY_DEFAULT,
NULL, create_async_inited, async_data);
}