From 6e99f5d9850d06cb2743c906843b429cb02173d2 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 4 Apr 2014 14:55:37 +0200 Subject: [PATCH] core: fix hanging pending_action "queued state lock" This bug caused nm-online to hang because "startup complete" state is never reached. Sometimes you also see this error in the logfile: (em1): add_pending_action (3): 'queued state lock' already added file devices/nm-device.c: line 7178 (nm_device_add_pending_action): should not be reached https://bugzilla.redhat.com/show_bug.cgi?id=1084554 https://bugzilla.redhat.com/show_bug.cgi?id=1084556 Related: https://bugzilla.redhat.com/show_bug.cgi?id=1082045 Signed-off-by: Thomas Haller (cherry picked from commit fc1351504db557b942c121b480fca661162702f7) --- src/devices/nm-device.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index c7f72b8..9cb79f2 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -6485,29 +6485,25 @@ nm_device_queue_state (NMDevice *self, priv = NM_DEVICE_GET_PRIVATE (self); - /* "lock" the pending actions so that if there was a previously - * queued action that's about to be cleared, that doesn't drop - * the pending actions to 0 before we add the new pending action. - */ - nm_device_add_pending_action (self, "queued state lock"); + if (priv->queued_state.id && priv->queued_state.state == state) + return; + + /* Add pending action for the new state before clearing the queued states, so + * that we don't accidently pop all pending states and reach 'startup complete' */ + nm_device_add_pending_action (self, queued_state_to_string (state)); /* We should only ever have one delayed state transition at a time */ if (priv->queued_state.id) { - if (priv->queued_state.state == state) - return; nm_log_warn (LOGD_DEVICE, "(%s): overwriting previously queued state change to %s (%s)", - nm_device_get_iface (self), - state_to_string (priv->queued_state.state), - reason_to_string (priv->queued_state.reason)); + nm_device_get_iface (self), + state_to_string (priv->queued_state.state), + reason_to_string (priv->queued_state.reason)); nm_device_queued_state_clear (self); } priv->queued_state.state = state; priv->queued_state.reason = reason; priv->queued_state.id = g_idle_add (queued_set_state, self); - nm_device_add_pending_action (self, queued_state_to_string (state)); - - nm_device_remove_pending_action (self, "queued state lock"); nm_log_dbg (LOGD_DEVICE, "(%s): queued state change to %s due to %s (id %d)", nm_device_get_iface (self), state_to_string (state), reason_to_string (reason), -- 1.9.0