cloud-setup: only pass config-iface-data as user-data for async functions

From config_iface_data->get_config_data we have access to the other pointer
already. No need to allocate a user data.

(cherry picked from commit 7d71aff247)
This commit is contained in:
Thomas Haller 2022-04-29 10:34:48 +02:00
parent 16ba58cfb1
commit a1d9fce147
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 34 additions and 40 deletions

View file

@ -129,24 +129,20 @@ typedef enum {
} GetConfigFetchDoneType;
static void
_get_config_fetch_done_cb(NMHttpClient *http_client,
GAsyncResult *result,
gpointer user_data,
GetConfigFetchDoneType fetch_type)
_get_config_fetch_done_cb(NMHttpClient *http_client,
GAsyncResult *result,
NMCSProviderGetConfigIfaceData *config_iface_data,
GetConfigFetchDoneType fetch_type)
{
NMCSProviderGetConfigTaskData *get_config_data;
gs_unref_bytes GBytes *response = NULL;
gs_free_error GError *error = NULL;
NMCSProviderGetConfigIfaceData *config_iface_data;
in_addr_t tmp_addr;
int tmp_prefix;
in_addr_t netmask_bin;
in_addr_t gateway_bin;
gs_free const char **s_addrs = NULL;
gsize i;
gsize len;
nm_utils_user_data_unpack(user_data, &get_config_data, &config_iface_data);
gs_unref_bytes GBytes *response = NULL;
gs_free_error GError *error = NULL;
in_addr_t tmp_addr;
int tmp_prefix;
in_addr_t netmask_bin;
in_addr_t gateway_bin;
gs_free const char **s_addrs = NULL;
gsize i;
gsize len;
nm_http_client_poll_get_finish(http_client, result, NULL, &response, &error);
@ -244,8 +240,9 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
}
out:
get_config_data->n_pending--;
_nmcs_provider_get_config_task_maybe_return(get_config_data, g_steal_pointer(&error));
config_iface_data->get_config_data->n_pending--;
_nmcs_provider_get_config_task_maybe_return(config_iface_data->get_config_data,
g_steal_pointer(&error));
}
static void
@ -379,7 +376,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_vpc_cidr_block,
nm_utils_user_data_pack(get_config_data, config_iface_data));
config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@ -396,7 +393,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_private_ipv4s,
nm_utils_user_data_pack(get_config_data, config_iface_data));
config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@ -413,7 +410,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_primary_ip_address,
nm_utils_user_data_pack(get_config_data, config_iface_data));
config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@ -430,7 +427,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_netmask,
nm_utils_user_data_pack(get_config_data, config_iface_data));
config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@ -447,7 +444,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_gateway,
nm_utils_user_data_pack(get_config_data, config_iface_data));
config_iface_data);
}
_nmcs_provider_get_config_task_maybe_return(get_config_data, NULL);

View file

@ -116,19 +116,15 @@ detect(NMCSProvider *provider, GTask *task)
/*****************************************************************************/
static void
_get_config_fetch_done_cb(NMHttpClient *http_client,
GAsyncResult *result,
gpointer user_data,
gboolean is_local_ipv4)
_get_config_fetch_done_cb(NMHttpClient *http_client,
GAsyncResult *result,
NMCSProviderGetConfigIfaceData *config_iface_data,
gboolean is_local_ipv4)
{
NMCSProviderGetConfigTaskData *get_config_data;
gs_unref_bytes GBytes *response = NULL;
gs_free_error GError *error = NULL;
NMCSProviderGetConfigIfaceData *config_iface_data;
in_addr_t tmp_addr;
int tmp_prefix;
nm_utils_user_data_unpack(user_data, &get_config_data, &config_iface_data);
gs_unref_bytes GBytes *response = NULL;
gs_free_error GError *error = NULL;
in_addr_t tmp_addr;
int tmp_prefix;
nm_http_client_poll_get_finish(http_client, result, NULL, &response, &error);
@ -173,8 +169,9 @@ _get_config_fetch_done_cb(NMHttpClient *http_client,
}
out:
get_config_data->n_pending--;
_nmcs_provider_get_config_task_maybe_return(get_config_data, g_steal_pointer(&error));
config_iface_data->get_config_data->n_pending--;
_nmcs_provider_get_config_task_maybe_return(config_iface_data->get_config_data,
g_steal_pointer(&error));
}
static void
@ -271,7 +268,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_subnet_ipv4_cidr_block,
nm_utils_user_data_pack(get_config_data, config_iface_data));
config_iface_data);
get_config_data->n_pending++;
nm_http_client_poll_get(
@ -288,7 +285,7 @@ _get_config_metadata_ready_cb(GObject *source, GAsyncResult *result, gpointer us
NULL,
NULL,
_get_config_fetch_done_cb_local_ipv4s,
nm_utils_user_data_pack(get_config_data, config_iface_data));
config_iface_data);
}
_nmcs_provider_get_config_task_maybe_return(get_config_data, NULL);