diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2017-04-13 15:13:02 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2017-04-13 17:18:34 +0200 |
commit | 67d144dd1e538cc753cbb581927f4b101726f271 (patch) | |
tree | a377a1a5a563a8ae5674fd2c122a92f2874f7d0e | |
parent | c4a0002f05fd0f57091b95646f1c9064e208ea66 (diff) | |
download | NetworkManager-67d144dd1e538cc753cbb581927f4b101726f271.tar.gz |
cli: check for deactivation failures
If the D-Bus call to DeactivateConnection() fails, don't wait for the
connection to change state because this is not going to
happen. Instead, notify the user of the error and, if necessary, wait
for remaining connections to be deactivated.
https://bugzilla.redhat.com/show_bug.cgi?id=1422786
-rw-r--r-- | clients/cli/connections.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/clients/cli/connections.c b/clients/cli/connections.c index 48454099f2..211d936305 100644 --- a/clients/cli/connections.c +++ b/clients/cli/connections.c @@ -2642,7 +2642,7 @@ do_connection_down (NmCli *nmc, int argc, char **argv) NMActiveConnection *active; ConnectionCbInfo *info = NULL; const GPtrArray *active_cons; - GSList *queue = NULL, *iter; + GSList *queue = NULL, *iter, *next; char **arg_arr = NULL; char **arg_ptr; int arg_num; @@ -2735,17 +2735,36 @@ do_connection_down (NmCli *nmc, int argc, char **argv) info->timeout_id = g_timeout_add_seconds (nmc->timeout, connection_op_timeout_cb, info); } - for (iter = queue; iter; iter = g_slist_next (iter)) { + iter = queue; + while (iter) { + GError *error = NULL; + + next = g_slist_next (iter); active = iter->data; - if (info) + if (info) { g_signal_connect (active, "notify::" NM_ACTIVE_CONNECTION_STATE, G_CALLBACK (down_active_connection_state_cb), info); + } /* Now deactivate the connection */ - nm_client_deactivate_connection (nmc->client, active, NULL, NULL); + if (!nm_client_deactivate_connection (nmc->client, active, NULL, &error)) { + g_print (_("Connection '%s' deactivation failed: %s\n"), + nm_active_connection_get_id (active), error->message); + g_error_free (error); + + if (info) { + g_signal_handlers_disconnect_by_func (active, + down_active_connection_state_cb, + info); + /* Remove the active connection from @queue */ + connection_cb_info_finish (info, active); + } + } + + iter = next; } finish: |