diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2016-10-18 16:35:07 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2016-11-10 16:48:48 +0100 |
commit | 1f5b48a59eb46c40cb10bf4381b2b21a19a9f471 (patch) | |
tree | ff92cacbfccf0c1b1bb09ee397c515bcd6b90b5e /libnm/nm-dbus-helpers.c | |
parent | ff3eb24c15154d2fa7aec9cb1882c63e83a65e70 (diff) | |
download | NetworkManager-1f5b48a59eb46c40cb10bf4381b2b21a19a9f471.tar.gz |
libnm: use the o.fd.DBus.ObjectManager API for object managementlr/object-manager
This speeds up the initial object tree load significantly. Also, it
reduces the object management complexity by shifting the duties to
GDBusObjectManager.
The lifetime of all NMObjects is now managed by the NMClient via the
object manager. The NMClient creates the NMObjects for GDBus objects,
triggers the initialization and serves as an object registry (replaces
the nm-cache).
The ObjectManager uses the o.fd.DBus.ObjectManager API to learn of the
object creation, removal and property changes. It takes care of the
property changes so that we don't have to and lets us always see a
consistent object state. Thus at the time we learn of a new object we
already know its properties.
The NMObject unfortunately can't be made synchronously initializable as
the NMRemoteConnection's settings are not managed with standard
o.fd.DBus Properties and ObjectManager APIs and thus are not known to
the ObjectManager. Thus most of the asynchronous object property
changing code in nm-object.c is preserved. The objects notify the
properties that reference them of their initialization in from their
init_finish() methods, thus the asynchronously created objects are not
allowed to fail creation (or the dependees would wait forever). Not a
problem -- if a connection can't get its Settings, it's either invisible
or being removed (presumably we'd learn of the removal from the object
manager soon).
The NMObjects can't be created by the object manager itself, since we
can't determine the resulting object type in proxy_type() yet (we can't
tell from the name and can't access the interface list). Therefore the
GDBusObject is coupled with a NMObject later on.
Lastly, now that all the objects are managed by the object manager, the
NMRemoteSettings and NMManager go away when the daemon is stopped. The
complexity of dealing with calls to NMClient that would require any of
the resources that these objects manage (connection or device lists,
etc.) had to be moved to NMClient. The bright side is that his allows
for removal all of the daemon presence tracking from NMObject.
Diffstat (limited to 'libnm/nm-dbus-helpers.c')
-rw-r--r-- | libnm/nm-dbus-helpers.c | 99 |
1 files changed, 1 insertions, 98 deletions
diff --git a/libnm/nm-dbus-helpers.c b/libnm/nm-dbus-helpers.c index 3076674a4f..f835b59141 100644 --- a/libnm/nm-dbus-helpers.c +++ b/libnm/nm-dbus-helpers.c @@ -98,24 +98,6 @@ _nm_dbus_is_connection_private (GDBusConnection *connection) return g_dbus_connection_get_unique_name (connection) == NULL; } -static GHashTable *proxy_types; - -#undef _nm_dbus_register_proxy_type -void -_nm_dbus_register_proxy_type (const char *interface, - GType proxy_type) -{ - if (!proxy_types) - proxy_types = g_hash_table_new (g_str_hash, g_str_equal); - - g_assert (g_hash_table_lookup (proxy_types, interface) == NULL); - g_hash_table_insert (proxy_types, (char *) interface, GSIZE_TO_POINTER (proxy_type)); -} - -/* We don't (currently) use GDBus's property-handling code */ -#define NM_DBUS_PROXY_FLAGS (G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | \ - G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START) - /* D-Bus has an upper limit on number of Match rules and it's rather easy * to hit as the proxy likes to add one for each object. Let's remove the Match * rule the proxy added and ensure a less granular rule is present instead. @@ -126,15 +108,13 @@ _nm_dbus_register_proxy_type (const char *interface, * Ideally, we should be able to tell glib not to hook its rules: * https://bugzilla.gnome.org/show_bug.cgi?id=758749 */ -static void +void _nm_dbus_proxy_replace_match (GDBusProxy *proxy) { GDBusConnection *connection = g_dbus_proxy_get_connection (proxy); static unsigned match_counter = 1024; gchar *match; - nm_assert (!g_strcmp0 (g_dbus_proxy_get_name (proxy), NM_DBUS_SERVICE)); - if (match_counter == 1) { /* If we hit the low matches watermark, install a * less granular one. */ @@ -177,83 +157,6 @@ _nm_dbus_proxy_replace_match (GDBusProxy *proxy) g_free (match); } -GDBusProxy * -_nm_dbus_new_proxy_for_connection (GDBusConnection *connection, - const char *path, - const char *interface, - GCancellable *cancellable, - GError **error) -{ - GDBusProxy *proxy; - GType proxy_type; - const char *name; - - proxy_type = GPOINTER_TO_SIZE (g_hash_table_lookup (proxy_types, interface)); - if (!proxy_type) - proxy_type = G_TYPE_DBUS_PROXY; - - if (_nm_dbus_is_connection_private (connection)) - name = NULL; - else - name = NM_DBUS_SERVICE; - - proxy = g_initable_new (proxy_type, cancellable, error, - "g-connection", connection, - "g-flags", NM_DBUS_PROXY_FLAGS, - "g-name", name, - "g-object-path", path, - "g-interface-name", interface, - NULL); - _nm_dbus_proxy_replace_match (proxy); - - return proxy; -} - -void -_nm_dbus_new_proxy_for_connection_async (GDBusConnection *connection, - const char *path, - const char *interface, - GCancellable *cancellable, - GAsyncReadyCallback callback, - gpointer user_data) -{ - GType proxy_type; - const char *name; - - proxy_type = GPOINTER_TO_SIZE (g_hash_table_lookup (proxy_types, interface)); - if (!proxy_type) - proxy_type = G_TYPE_DBUS_PROXY; - - if (_nm_dbus_is_connection_private (connection)) - name = NULL; - else - name = NM_DBUS_SERVICE; - - g_async_initable_new_async (proxy_type, G_PRIORITY_DEFAULT, - cancellable, callback, user_data, - "g-connection", connection, - "g-flags", NM_DBUS_PROXY_FLAGS, - "g-name", name, - "g-object-path", path, - "g-interface-name", interface, - NULL); -} - -GDBusProxy * -_nm_dbus_new_proxy_for_connection_finish (GAsyncResult *result, - GError **error) -{ - GObject *source; - GDBusProxy *proxy; - - source = g_async_result_get_source_object (result); - proxy = G_DBUS_PROXY (g_async_initable_new_finish (G_ASYNC_INITABLE (source), result, error)); - g_object_unref (source); - _nm_dbus_proxy_replace_match (proxy); - - return proxy; -} - /* Binds the properties on a generated server-side GDBus object to the * corresponding properties on the public object. */ |