diff options
author | Thomas Haller <thaller@redhat.com> | 2020-02-26 12:27:36 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-02-26 12:27:36 +0100 |
commit | b15a9b3dc4459f228e699a5cf6a3bd4a5ff71ee3 (patch) | |
tree | 9c6b0aa54516e4b454c7c4a7928ea7491e805c7b /src/supplicant/nm-supplicant-interface.c | |
parent | 9add51ef16356da81a0fd5a8f3f0ddebeb093636 (diff) |
supplicant: allocate blobs hash table lazily for supplicant config
It's very unlikely that we have actual blobs for a Wi-Fi network.
That is because the settings plugins (keyfile, ifcfg-rh) convert
blobs to files on disk when writing the profile. So, you can only
have them by editing the files directly to contain blobs.
At that point, don't always create the GHashTable for blobs.
Diffstat (limited to 'src/supplicant/nm-supplicant-interface.c')
-rw-r--r-- | src/supplicant/nm-supplicant-interface.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/supplicant/nm-supplicant-interface.c b/src/supplicant/nm-supplicant-interface.c index fca997aa2d..04f35e4182 100644 --- a/src/supplicant/nm-supplicant-interface.c +++ b/src/supplicant/nm-supplicant-interface.c @@ -2154,26 +2154,29 @@ assoc_add_network_cb (GDBusProxy *proxy, GAsyncResult *result, gpointer user_dat /* Send blobs first; otherwise jump to selecting the network */ blobs = nm_supplicant_config_get_blobs (priv->assoc_data->cfg); - priv->assoc_data->blobs_left = g_hash_table_size (blobs); + priv->assoc_data->blobs_left = blobs + ? g_hash_table_size (blobs) + : 0u; _LOGT ("assoc[%p]: network added (%s) (%u blobs left)", priv->assoc_data, priv->net_path, priv->assoc_data->blobs_left); - if (priv->assoc_data->blobs_left == 0) + if (priv->assoc_data->blobs_left == 0) { assoc_call_select_network (self); - else { - g_hash_table_iter_init (&iter, blobs); - while (g_hash_table_iter_next (&iter, (gpointer) &blob_name, (gpointer) &blob_data)) { - g_dbus_proxy_call (priv->iface_proxy, - "AddBlob", - g_variant_new ("(s@ay)", - blob_name, - nm_utils_gbytes_to_variant_ay (blob_data)), - G_DBUS_CALL_FLAGS_NONE, - -1, - priv->assoc_data->cancellable, - (GAsyncReadyCallback) assoc_add_blob_cb, - self); - } + return; + } + + g_hash_table_iter_init (&iter, blobs); + while (g_hash_table_iter_next (&iter, (gpointer) &blob_name, (gpointer) &blob_data)) { + g_dbus_proxy_call (priv->iface_proxy, + "AddBlob", + g_variant_new ("(s@ay)", + blob_name, + nm_utils_gbytes_to_variant_ay (blob_data)), + G_DBUS_CALL_FLAGS_NONE, + -1, + priv->assoc_data->cancellable, + (GAsyncReadyCallback) assoc_add_blob_cb, + self); } } |