diff options
author | Francesco Giudici <fgiudici@redhat.com> | 2017-04-05 10:48:16 +0200 |
---|---|---|
committer | Francesco Giudici <fgiudici@redhat.com> | 2017-04-05 11:16:32 +0200 |
commit | 0d03a730b0ee4b0e8be7e52be70d11e2465d45ae (patch) | |
tree | a0c617d8732417e2ffff7dbdd896a22fadd4985b | |
parent | 423f8b6ebdc64f0fd74aafd91af8e4aee009a013 (diff) | |
download | NetworkManager-fg/nmcli_fix_bridge_up.tar.gz |
nmcli: avoid calling twice "check_activated()" on "nmcli connection up"fg/nmcli_fix_bridge_up
This happens when the connection is in "activating" state and
the connection is a master one waiting for slaves: "check_activated()"
is called by the active_connection_state_cb() and device_state_cb() callbacks.
If the device has already moved to a state >= NM_DEVICE_STATE_IP_CONFIG, the
call to active_connection_state_cb() will end calling
activate_connection_info_finish(), freeing the "info" object. The subsequent
call to device_state_cb() will result in accessing the freed "info".
Just call check_activated() once after registering the
active_connection_state() and device_state_cb() callbacks.
-rw-r--r-- | clients/cli/connections.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 72c91df25d..630cefb303 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -2369,17 +2369,16 @@ activate_connection_cb (GObject *client, GAsyncResult *result, gpointer user_dat } activate_connection_info_finish (info); } else { - /* Monitor the active connection state state */ - g_signal_connect (G_OBJECT (active), "state-changed", G_CALLBACK (active_connection_state_cb), info); - active_connection_state_cb (active, - nm_active_connection_get_state (active), - nm_active_connection_get_state_reason (active), - info); - - if (device) { + /* Monitor the active connection and device (if available) states */ + g_signal_connect (active, "state-changed", G_CALLBACK (active_connection_state_cb), info); + if (device) g_signal_connect (device, "notify::" NM_DEVICE_STATE, G_CALLBACK (device_state_cb), info); - device_state_cb (device, NULL, info); - } + /* Both active_connection_state_cb () and device_state_cb () will just + * call check_activated (info). So, just call it once directly after + * connecting on both the signals of the objects and skip the call to + * the callbacks. + */ + check_activated (info); /* Start progress indication showing VPN states */ if (nmc->nmc_config.print_output == NMC_PRINT_PRETTY) { |