device: handle master-ready before scheduling stage2

Don't handle master-ready at the beginning of stage2, but instead while
scheduling (and then possibly delaying the scheduling of stage2).

This seems more idiomatic:

  When inside a stage and your part is done: call schedule-next-stage.
  That is, always schedule the next stage, not the current one.
  schedule-next-stage then might delay to really scheduling until the
  device is ready for the next state.

Fixes: 85ac903bb8
This commit is contained in:
Thomas Haller 2015-10-06 12:03:51 +02:00
parent c5210b322d
commit 7bbc090387

View file

@ -2992,28 +2992,6 @@ nm_device_activate_stage2_device_config (gpointer user_data)
/* Clear the activation source ID now that this stage has run */
activation_source_clear (self, FALSE, 0);
if (!priv->master_ready_handled) {
if (!nm_active_connection_get_master (active))
priv->master_ready_handled = TRUE;
else {
/* If the master connection is ready for slaves, attach ourselves */
if (nm_active_connection_get_master_ready (active))
master_ready (self, active);
else {
_LOGD (LOGD_DEVICE, "waiting for master connection to become ready");
if (priv->master_ready_id == 0) {
priv->master_ready_id = g_signal_connect (active,
"notify::" NM_ACTIVE_CONNECTION_INT_MASTER_READY,
(GCallback) master_ready_cb,
self);
}
/* Postpone */
return FALSE;
}
}
}
_LOGD (LOGD_DEVICE, "Activation: Stage 2 of 5 (Device Configure) starting...");
nm_device_state_changed (self, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE);
@ -3075,6 +3053,30 @@ nm_device_activate_schedule_stage2_device_config (NMDevice *self)
priv = NM_DEVICE_GET_PRIVATE (self);
g_return_if_fail (priv->act_request);
if (!priv->master_ready_handled) {
NMActiveConnection *active = NM_ACTIVE_CONNECTION (priv->act_request);
if (!nm_active_connection_get_master (active))
priv->master_ready_handled = TRUE;
else {
/* If the master connection is ready for slaves, attach ourselves */
if (nm_active_connection_get_master_ready (active))
master_ready (self, active);
else {
_LOGD (LOGD_DEVICE, "waiting for master connection to become ready");
if (priv->master_ready_id == 0) {
priv->master_ready_id = g_signal_connect (active,
"notify::" NM_ACTIVE_CONNECTION_INT_MASTER_READY,
(GCallback) master_ready_cb,
self);
}
/* Postpone */
return;
}
}
}
activation_source_schedule (self, nm_device_activate_stage2_device_config, 0);
_LOGD (LOGD_DEVICE, "Activation: Stage 2 of 5 (Device Configure) scheduled...");