mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 06:40:11 +01:00
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.
This commit is contained in:
parent
9add51ef16
commit
b15a9b3dc4
2 changed files with 25 additions and 21 deletions
|
|
@ -88,10 +88,6 @@ nm_supplicant_config_init (NMSupplicantConfig * self)
|
|||
g_free,
|
||||
(GDestroyNotify) config_option_free);
|
||||
|
||||
priv->blobs = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify) g_bytes_unref);
|
||||
|
||||
priv->ap_scan = 1;
|
||||
priv->dispose_has_run = FALSE;
|
||||
}
|
||||
|
|
@ -224,6 +220,11 @@ nm_supplicant_config_add_blob (NMSupplicantConfig *self,
|
|||
nm_log_info (LOGD_SUPPLICANT, "Config: added '%s' value '%s'", key, opt->value);
|
||||
|
||||
g_hash_table_insert (priv->config, g_strdup (key), opt);
|
||||
if (!priv->blobs) {
|
||||
priv->blobs = g_hash_table_new_full (nm_str_hash, g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify) g_bytes_unref);
|
||||
}
|
||||
g_hash_table_insert (priv->blobs,
|
||||
g_strdup (blobid),
|
||||
g_bytes_ref (value));
|
||||
|
|
@ -259,7 +260,7 @@ nm_supplicant_config_finalize (GObject *object)
|
|||
NMSupplicantConfigPrivate *priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (object);
|
||||
|
||||
g_hash_table_destroy (priv->config);
|
||||
g_hash_table_destroy (priv->blobs);
|
||||
nm_clear_pointer (&priv->blobs, g_hash_table_destroy);
|
||||
|
||||
G_OBJECT_CLASS (nm_supplicant_config_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue