summaryrefslogtreecommitdiff
path: root/libnm/nm-client.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-09-02 10:35:37 +0200
committerThomas Haller <thaller@redhat.com>2019-09-27 16:28:15 +0200
commitfd0a2af47013e2ea59bcd0f71850d7fcbec29fc1 (patch)
treecc4ad3ccbff661a1bb4ae1c19da91f4fc83bd767 /libnm/nm-client.c
parent1a3006fd7440c4a1b0d131992b07e17de1cba834 (diff)
downloadNetworkManager-th/libnm-dbus-rework.tar.gz
libnm: add nm-dbus-client.[hc]th/libnm-dbus-rework
This new code will interact with the D-Bus interface of NetworkManager to realize the client-side cache of objects (what libnm has). This is more complicated because of libnm's API, because of the following: (1) libnm should never perform any blocking D-Bus calls. That allows to schedule and process calls in parallel, and also lets us get the order of events right. That is especially relevant, because we want and *must* make certain calls asynchronously. It's impossible to correctly mix asynchronous and synchronous calls without messing up the order of events. Hence, all D-Bus of libnm calls must be made asynchronously internally. (2) libnm has blocking calls of two kinds. Blocking calls fundamentally are wrong and I wish we shouldn't have them. Also, they complicate the implementation of this by an order of magnitude, and have a clear performance overhead. They are wrong, because during the blocking call, we clearly don't want to invoke *any* events. For example, no NM_CLIENT_DEVICE_ADDED signals, and no property changed signals from the libnm cache. Otherwise, the call wouldn't be very blocking. Everything that happens to the state of the cache while the blocking call is pending, must be invoked only afterwards (but still in the right order!). We have some blocking calls that merely make a D-Bus call. For example, nm_manager_deactivate_connection(). This does the blocking D-Bus call and returns, but afterwards the state of the client cache is not yet caught up. Whether such a behavior makes any sense at all is questionable, because the cache will still contain the active connection in state ACTIVATED. Changes to the cache will only be visible when iterating the main context again. While this kind of calls is simple to implement, it's also pretty pointless and probably shouldn't behave like this. Other blocking calls are more complicated. (2a) blocking calls that merely perform a blocking D-Bus call. A blocking call like g_dbus_connection_call_sync() will not process any events, while waiting for the reply. That is implemented by
Diffstat (limited to 'libnm/nm-client.c')
-rw-r--r--libnm/nm-client.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libnm/nm-client.c b/libnm/nm-client.c
index 1e81221537..2c09698986 100644
--- a/libnm/nm-client.c
+++ b/libnm/nm-client.c
@@ -20,6 +20,7 @@
#include "nm-active-connection.h"
#include "nm-vpn-connection.h"
#include "nm-remote-connection.h"
+#include "nm-dbus-client.h"
#include "nm-dbus-helpers.h"
#include "nm-wimax-nsp.h"
#include "nm-object-private.h"
@@ -96,6 +97,7 @@ typedef struct {
typedef struct {
NMManager *manager;
+ NMDBusClient *dbus_client;
NMRemoteSettings *settings;
NMDnsManager *dns_manager;
GDBusObjectManager *object_manager;
@@ -168,9 +170,17 @@ NM_CACHED_QUARK_FCN ("nm-client-error-quark", nm_client_error_quark)
/*****************************************************************************/
+static const NMDBusClientCallbackTable dbus_client_callback_table = {
+};
+
static void
nm_client_init (NMClient *client)
{
+ NMClientPrivate *priv = NM_CLIENT_GET_PRIVATE (client);
+
+ priv->dbus_client = nm_dbus_client_new (g_bus_get_sync (_nm_dbus_bus_type (), NULL, NULL),
+ &dbus_client_callback_table,
+ client);
}
static gboolean
@@ -3408,6 +3418,8 @@ dispose (GObject *object)
nm_clear_g_cancellable (&priv->new_object_manager_cancellable);
+ nm_clear_pointer (&priv->dbus_client, nm_dbus_client_free);
+
if (priv->manager) {
g_signal_handlers_disconnect_by_data (priv->manager, object);
g_clear_object (&priv->manager);