diff options
author | Jiří Klimeš <jklimes@redhat.com> | 2014-11-10 16:56:34 +0100 |
---|---|---|
committer | Jiří Klimeš <jklimes@redhat.com> | 2014-11-10 17:22:52 +0100 |
commit | b75dfc62e899098e1178fddf991dce2772c51eec (patch) | |
tree | 1327f77c680579c0d24b75af3f1dcb995a1dd45a | |
parent | a14bc5f67c5ed414520a64c8684a21696d35fa81 (diff) | |
download | NetworkManager-b75dfc62e899098e1178fddf991dce2772c51eec.tar.gz |
cli: fix nmcli timeout when disconnecting a device
$ nmcli dev disconnect nm-bond
Error: Timeout 10 sec expired.
When a software device is disconnected, it will be removed. And it may not go
to NM_DEVICE_STATE_DISCONNECTED state before that. So we need to listen to
"device-removed" signal.
Fixes:Beaker:test_log-NetworkManager_Test189_bond_activate
-rw-r--r-- | clients/cli/devices.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/clients/cli/devices.c b/clients/cli/devices.c index ae8664e987..3703743957 100644 --- a/clients/cli/devices.c +++ b/clients/cli/devices.c @@ -1598,18 +1598,29 @@ error: static void disconnect_state_cb (NMDevice *device, GParamSpec *pspec, gpointer user_data) { - NmCli *nmc = (NmCli *) user_data; NMDeviceState state; state = nm_device_get_state (device); if (state == NM_DEVICE_STATE_DISCONNECTED) { - g_string_printf (nmc->return_text, _("Success: Device '%s' successfully disconnected."), nm_device_get_iface (device)); + g_signal_handlers_disconnect_by_data (device, user_data); + g_print (_("Device '%s' successfully disconnected.\n"), + nm_device_get_iface (device)); quit (); } } static void +device_removed_cb (NMClient *client, NMDevice *device, gpointer user_data) +{ + /* Success: device has been removed. It happens when disconnecting a software device. */ + g_signal_handlers_disconnect_by_data (client, user_data); + g_print (_("Device '%s' successfully disconnected.\n"), + nm_device_get_iface (device)); + quit (); +} + +static void disconnect_device_cb (GObject *object, GAsyncResult *result, gpointer user_data) { NMDevice *device = NM_DEVICE (object); @@ -1638,6 +1649,7 @@ disconnect_device_cb (GObject *object, GAsyncResult *result, gpointer user_data) quit (); } else { g_signal_connect (device, "notify::state", G_CALLBACK (disconnect_state_cb), nmc); + g_signal_connect (nmc->client, NM_CLIENT_DEVICE_REMOVED, G_CALLBACK (device_removed_cb), nmc); /* Start timer not to loop forever if "notify::state" signal is not issued */ g_timeout_add_seconds (nmc->timeout, timeout_cb, nmc); } |