summaryrefslogtreecommitdiff
path: root/shared/nm-libnm-aux/nm-libnm-aux.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared/nm-libnm-aux/nm-libnm-aux.c')
-rw-r--r--shared/nm-libnm-aux/nm-libnm-aux.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/shared/nm-libnm-aux/nm-libnm-aux.c b/shared/nm-libnm-aux/nm-libnm-aux.c
index 83b6f71b6b..169416b9c4 100644
--- a/shared/nm-libnm-aux/nm-libnm-aux.c
+++ b/shared/nm-libnm-aux/nm-libnm-aux.c
@@ -102,6 +102,31 @@ nmc_client_new_waitsync (GCancellable *cancellable,
};
va_list ap;
+#if NM_MORE_ASSERTS > 10
+ /* The sync initialization of NMClient is generally a bad idea, because it
+ * brings the overhead of an additional GMainContext. Anyway, since our own
+ * code no longer uses that, we hardly test those code paths. But they should
+ * work just the same. Randomly use instead the sync initialization in a debug
+ * build... */
+ if ((g_random_int () % 2) == 0) {
+ gboolean success;
+
+ va_start (ap, first_property_name);
+ nmc = NM_CLIENT (g_object_new_valist (NM_TYPE_CLIENT, first_property_name, ap));
+ va_end (ap);
+
+ /* iterate the context at least once, just so that the behavior from POV of the
+ * caller is roughly the same. */
+ g_main_context_iteration (nm_client_get_main_context (nmc), FALSE);
+
+ success = g_initable_init (G_INITABLE (nmc),
+ cancellable,
+ error);
+ NM_SET_OUT (out_nmc, g_steal_pointer (&nmc));
+ return success;
+ }
+#endif
+
va_start (ap, first_property_name);
nmc = nmc_client_new_async_valist (cancellable,
_nmc_client_new_waitsync_cb,