From 5859e9a53d8f2170ed468ea0d77020c5849c0f8c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 6 Dec 2019 13:02:31 +0100 Subject: [PATCH] tui: create NMClient instance via async init Using sync init (nm_client_new()) has an overhead as it requires an internal GMainContext to ensure preserving the order of D-Bus messages. Let's avoid that by using the async init. Note that the difference here is that we will iterate the caller's GMainContext while creating the instance. But that is no problem for nmtui at that point. --- Makefile.am | 1 + clients/tui/meson.build | 1 + clients/tui/nmtui.c | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 748c0c9ef2..6c29e44ff2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4640,6 +4640,7 @@ clients_tui_nmtui_LDADD = \ clients/tui/newt/libnmt-newt.a \ clients/common/libnmc.la \ clients/common/libnmc-base.la \ + shared/nm-libnm-aux/libnm-libnm-aux.la \ shared/nm-libnm-core-aux/libnm-libnm-core-aux.la \ shared/nm-libnm-core-intern/libnm-libnm-core-intern.la \ shared/nm-glib-aux/libnm-glib-aux.la \ diff --git a/clients/tui/meson.build b/clients/tui/meson.build index 8948d6ff35..db6bd429fd 100644 --- a/clients/tui/meson.build +++ b/clients/tui/meson.build @@ -51,6 +51,7 @@ deps = [ libnmc_base_dep, libnmc_dep, libnmt_newt_dep, + libnm_libnm_aux_dep, ] executable( diff --git a/clients/tui/nmtui.c b/clients/tui/nmtui.c index e9d2ab506b..dcd8973772 100644 --- a/clients/tui/nmtui.c +++ b/clients/tui/nmtui.c @@ -18,6 +18,8 @@ #include #include +#include "nm-libnm-aux/nm-libnm-aux.h" + #include "nmt-newt.h" #include "nm-editor-bindings.h" @@ -231,8 +233,10 @@ main (int argc, char **argv) nm_editor_bindings_init (); - nm_client = nm_client_new (NULL, &error); - if (!nm_client) { + if (!nmc_client_new_waitsync (NULL, + &nm_client, + &error, + NULL)) { g_printerr (_("Could not contact NetworkManager: %s.\n"), error->message); g_error_free (error); exit (1);