mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 12:40:16 +01:00
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
This commit is contained in:
parent
a14bc5f67c
commit
b75dfc62e8
1 changed files with 14 additions and 2 deletions
|
|
@ -1598,17 +1598,28 @@ 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)
|
||||
{
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue