core: simplify nm_device_activate()

We don't need to check device state here because the manager, which
is the only thing that calls nm_device_activate() in
internal_activate_device() ensures that the device is deactivated
before starting a new activation request.
This commit is contained in:
Dan Williams 2012-11-13 17:36:39 -06:00
parent 0ada524a82
commit 6116a84048
3 changed files with 10 additions and 26 deletions

View file

@ -3408,16 +3408,16 @@ act_dep_result_cb (NMActRequest *req,
}
}
gboolean
nm_device_activate (NMDevice *self, NMActRequest *req, GError **error)
void
nm_device_activate (NMDevice *self, NMActRequest *req)
{
NMDevicePrivate *priv;
NMConnection *connection;
g_return_val_if_fail (self != NULL, FALSE);
g_return_val_if_fail (NM_IS_DEVICE (self), FALSE);
g_return_val_if_fail (req != NULL, FALSE);
g_return_val_if_fail (NM_IS_ACT_REQUEST (req), FALSE);
g_return_if_fail (self != NULL);
g_return_if_fail (NM_IS_DEVICE (self));
g_return_if_fail (req != NULL);
g_return_if_fail (NM_IS_ACT_REQUEST (req));
priv = NM_DEVICE_GET_PRIVATE (self);
@ -3428,20 +3428,7 @@ nm_device_activate (NMDevice *self, NMActRequest *req, GError **error)
nm_device_get_iface (self),
nm_connection_get_id (connection));
/* Make sure this connection isn't activated already, or in the process of
* being activated.
*/
if ( nm_device_is_activating (self)
|| (nm_device_get_state (self) == NM_DEVICE_STATE_ACTIVATED)) {
NMConnection *new = nm_act_request_get_connection (req);
NMConnection *current = nm_act_request_get_connection (priv->act_request);
if (new == current) {
g_set_error_literal (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_CONNECTION_ACTIVATING,
"Connection is already activating");
return FALSE;
}
}
g_warn_if_fail (priv->state == NM_DEVICE_STATE_DISCONNECTED);
priv->act_request = g_object_ref (req);
g_object_notify (G_OBJECT (self), NM_DEVICE_ACTIVE_CONNECTION);
@ -3493,8 +3480,6 @@ nm_device_activate (NMDevice *self, NMActRequest *req, GError **error)
nm_device_state_changed (self, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE);
nm_device_activate_schedule_stage3_ip_config_start (self);
}
return TRUE;
}
/*

View file

@ -285,7 +285,7 @@ void nm_device_queue_state (NMDevice *self,
gboolean nm_device_get_firmware_missing (NMDevice *self);
gboolean nm_device_activate (NMDevice *device, NMActRequest *req, GError **error);
void nm_device_activate (NMDevice *device, NMActRequest *req);
void nm_device_set_connection_provider (NMDevice *device, NMConnectionProvider *provider);

View file

@ -2289,7 +2289,6 @@ internal_activate_device (NMManager *manager,
GError **error)
{
NMActRequest *req;
gboolean success;
g_return_val_if_fail (NM_IS_MANAGER (manager), NULL);
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
@ -2316,10 +2315,10 @@ internal_activate_device (NMManager *manager,
assumed,
(gpointer) device,
master);
success = nm_device_activate (device, req, error);
nm_device_activate (device, req);
g_object_unref (req);
return success ? NM_ACTIVE_CONNECTION (req) : NULL;
return NM_ACTIVE_CONNECTION (req);
}
/**