nmcli: avoid calling twice "check_activated()" on "nmcli connection 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.

(cherry picked from commit 3d4d1bedda)
This commit is contained in:
Francesco Giudici 2017-04-05 10:48:16 +02:00
parent ff3eace902
commit 77e1304f73

View file

@ -2355,17 +2355,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->print_output == NMC_PRINT_PRETTY) {