diff options
author | Thomas Haller <thaller@redhat.com> | 2017-03-13 18:45:36 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-03-15 10:33:44 +0100 |
commit | 6845b9b80a9fcec9d2c9e7b56a37329f38089f2e (patch) | |
tree | 43665f689d0b5817215a879e8963d52fe4d09b68 | |
parent | 22b7282d843f24442aed6a72617e0038f572b2c9 (diff) | |
download | NetworkManager-6845b9b80a9fcec9d2c9e7b56a37329f38089f2e.tar.gz |
device: delay startup complete until device is initialized in platform
Udev may be slow at startup and it may take a while until the
device is visible in udev. Before that, there are no pending
actions yet because the device is still in unmanaged state.
Hack nm_device_has_pending_action() to indicate a pending action
when the platform link is not yet initialized.
We don't bother using nm_device_add_pending_action() to schedule
a proper pending-action. It is simpler this way, also we precisely
log about the state of NM_UNMANAGED_PLATFORM_INIT flag. The pending
actions are implemented in their way mostly for logging purpose to
understand what blocks a device. For NM_UNMANAGED_PLATFORM_INIT we
have sufficient logging so no need for the overhead and effort.
https://bugzilla.gnome.org/show_bug.cgi?id=779920
-rw-r--r-- | src/devices/nm-device.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index cfa91951a0..3737756236 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -10645,6 +10645,8 @@ _set_unmanaged_flags (NMDevice *self, const char *operation = NULL; char str1[512]; char str2[512]; + gboolean do_notify_has_pending_actions = FALSE; + gboolean had_pending_actions = FALSE; g_return_if_fail (NM_IS_DEVICE (self)); g_return_if_fail (flags); @@ -10680,6 +10682,11 @@ _set_unmanaged_flags (NMDevice *self, nm_assert_se (!nm_clear_g_source (&priv->queued_ip6_config_id)); priv->queued_ip6_config_id = g_idle_add (queued_ip6_config_change, self); } + + if (!priv->pending_actions) { + do_notify_has_pending_actions = TRUE; + had_pending_actions = nm_device_has_pending_action (self); + } } old_flags = priv->unmanaged_flags; @@ -10739,6 +10746,10 @@ _set_unmanaged_flags (NMDevice *self, "")); #undef _FMT + if ( do_notify_has_pending_actions + && had_pending_actions != nm_device_has_pending_action (self)) + _notify (self, PROP_HAS_PENDING_ACTION); + if (transition_state) { new_state = was_managed ? NM_DEVICE_STATE_UNMANAGED : NM_DEVICE_STATE_UNAVAILABLE; if (now) @@ -11412,7 +11423,16 @@ nm_device_has_pending_action (NMDevice *self) { NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self); - return !!priv->pending_actions; + if (priv->pending_actions) + return TRUE; + + if (nm_device_get_unmanaged_flags (self, NM_UNMANAGED_PLATFORM_INIT)) { + /* as long as the platform link is not yet initialized, we have a pending + * action. */ + return TRUE; + } + + return FALSE; } /*****************************************************************************/ |