Commit 23b0619e authored by Dan Williams's avatar Dan Williams
Browse files

2005-10-02 Dan Williams <dcbw@redhat.com>

	* Shorten time taken to sleep by fastpathing bits of device deactivation
		necessary for sleep.

	* Fix issue where deactivating a device might deactivate the active
		VPN connection, even if the VPN was not using the device.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@985 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 92bb1e64
2005-10-02 Dan Williams <dcbw@redhat.com>
* Shorten time taken to sleep by fastpathing bits of device deactivation
necessary for sleep.
* Fix issue where deactivating a device might deactivate the active
VPN connection, even if the VPN was not using the device.
2005-10-02 Dan Williams <dcbw@redhat.com>
* gnome/applet/applet.c
......
......@@ -1059,6 +1059,7 @@ static void nmwa_update_state (NMWirelessApplet *applet)
switch (applet->nm_state)
{
case NM_STATE_ASLEEP:
case NM_STATE_DISCONNECTED:
pixbuf = applet->no_connection_icon;
tip = g_strdup (_("No network connection"));
......
......@@ -44,6 +44,7 @@
#include "NetworkManagerAPList.h"
#include "NetworkManagerSystem.h"
#include "nm-named-manager.h"
#include "nm-vpn-act-request.h"
#include "nm-dbus-vpn.h"
#include "nm-netlink-monitor.h"
#include "nm-dhcp-manager.h"
......@@ -360,6 +361,7 @@ void nm_schedule_state_change_signal_broadcast (NMData *data)
g_return_if_fail (data != NULL);
source = g_idle_source_new ();
g_source_set_priority (source, G_PRIORITY_HIGH);
g_source_set_callback (source, nm_state_change_signal_broadcast, data, NULL);
id = g_source_attach (source, data->main_context);
g_source_unref (source);
......@@ -452,11 +454,13 @@ static void device_stop_and_free (NMDevice *dev, gpointer user_data)
*/
static void nm_data_free (NMData *data)
{
NMVPNActRequest *req;
g_return_if_fail (data != NULL);
/* Kill any active VPN connection */
if (nm_vpn_manager_get_vpn_act_request (data->vpn_manager))
nm_vpn_manager_deactivate_vpn_connection (data->vpn_manager);
if ((req = nm_vpn_manager_get_vpn_act_request (data->vpn_manager)))
nm_vpn_manager_deactivate_vpn_connection (data->vpn_manager, nm_vpn_act_request_get_parent_dev (req));
/* Stop and destroy all devices */
nm_lock_mutex (data->dev_list_mutex, __FUNCTION__);
......
......@@ -3162,19 +3162,19 @@ void nm_device_activation_cancel (NMDevice *dev)
/*
* nm_device_deactivate
* nm_device_deactivate_quickly
*
* Remove a device's routing table entries and IP address.
* Quickly deactivate a device, for things like sleep, etc. Doesn't
* clean much stuff up, and nm_device_deactivate() should be called
* on the device eventually.
*
*/
gboolean nm_device_deactivate (NMDevice *dev)
gboolean nm_device_deactivate_quickly (NMDevice *dev)
{
NMIP4Config * config;
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (dev->app_data != NULL, FALSE);
nm_info ("Deactivating device %s.", nm_device_get_iface (dev));
nm_vpn_manager_deactivate_vpn_connection (dev->app_data->vpn_manager, dev);
if (nm_device_is_activated (dev))
nm_dbus_schedule_device_status_change_signal (dev->app_data, dev, NULL, DEVICE_NO_LONGER_ACTIVE);
......@@ -3191,11 +3191,30 @@ gboolean nm_device_deactivate (NMDevice *dev)
dev->act_request = NULL;
}
return TRUE;
}
/*
* nm_device_deactivate
*
* Remove a device's routing table entries and IP address.
*
*/
gboolean nm_device_deactivate (NMDevice *dev)
{
NMIP4Config * config;
g_return_val_if_fail (dev != NULL, FALSE);
g_return_val_if_fail (dev->app_data != NULL, FALSE);
nm_info ("Deactivating device %s.", nm_device_get_iface (dev));
nm_device_deactivate_quickly (dev);
if (nm_device_get_driver_support_level (dev) == NM_DRIVER_UNSUPPORTED)
return TRUE;
nm_vpn_manager_deactivate_vpn_connection (dev->app_data->vpn_manager);
/* Remove any device nameservers and domains */
if ((config = nm_device_get_ip4_config (dev)))
{
......
......@@ -108,6 +108,7 @@ void nm_device_activate_schedule_stage4_ip_config_timeout (NMActRequest *req);
void nm_device_activation_cancel (NMDevice *dev);
gboolean nm_device_activation_should_cancel (NMDevice *dev);
gboolean nm_device_is_activating (NMDevice *dev);
gboolean nm_device_deactivate_quickly (NMDevice *dev);
gboolean nm_device_deactivate (NMDevice *dev);
NMAccessPoint *nm_device_wireless_get_activation_ap (NMDevice *dev, const char *essid, const char *key, NMEncKeyType key_type);
......
......@@ -326,7 +326,8 @@ void nm_dhcp_manager_cancel_transaction (NMDHCPManager *manager, NMActRequest *r
/* FIXME: we should really monitor the interface's DHCP state by waiting
* for dhcdbd to tell us the device is "down" rather than sleeping here.
*/
sleep (1);
if (!manager->data->asleep)
sleep (1);
}
g_free (path);
......
......@@ -469,27 +469,29 @@ static DBusMessage *nm_dbus_nm_sleep (DBusConnection *connection, DBusMessage *m
app_data = data->data;
if (app_data->asleep == FALSE)
{
GSList *elt;
nm_info ("Going to sleep.");
app_data->asleep = TRUE;
/* Not using nm_schedule_state_change_signal_broadcast() here
* because we want the signal to go out ASAP.
*/
nm_dbus_signal_state_change (connection, app_data);
/* Remove all devices from the device list */
nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
while (g_slist_length (app_data->dev_list))
for (elt = app_data->dev_list; elt; elt = g_slist_next (elt))
{
NMDevice *dev = (NMDevice *)(app_data->dev_list->data);
fprintf (stderr, "dev %p\n", dev);
nm_remove_device (app_data, dev);
NMDevice *dev = (NMDevice *)(elt->data);
nm_device_set_removed (dev, TRUE);
nm_device_deactivate_quickly (dev);
}
nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
nm_lock_mutex (app_data->dialup_list_mutex, __FUNCTION__);
nm_system_deactivate_all_dialup (app_data->dialup_list);
nm_unlock_mutex (app_data->dialup_list_mutex, __FUNCTION__);
nm_schedule_state_change_signal_broadcast (app_data);
nm_policy_schedule_device_change_check (data->data);
}
return NULL;
......@@ -507,6 +509,12 @@ static DBusMessage *nm_dbus_nm_wake (DBusConnection *connection, DBusMessage *me
nm_info ("Waking up from sleep.");
app_data->asleep = FALSE;
/* Remove all devices from the device list */
nm_lock_mutex (app_data->dev_list_mutex, __FUNCTION__);
while (g_slist_length (app_data->dev_list))
nm_remove_device (app_data, (NMDevice *)(app_data->dev_list->data));
nm_unlock_mutex (app_data->dev_list_mutex, __FUNCTION__);
nm_add_initial_devices (app_data);
nm_schedule_state_change_signal_broadcast (app_data);
......
......@@ -749,7 +749,7 @@ static DBusMessage *nm_dbus_vpn_deactivate_connection (DBusConnection *connectio
nm_info ("Will deactivate the VPN connection '%s', service '%s'.", nm_vpn_connection_get_name (vpn),
nm_vpn_connection_get_service_name (vpn));
nm_vpn_manager_deactivate_vpn_connection (data->data->vpn_manager);
nm_vpn_manager_deactivate_vpn_connection (data->data->vpn_manager, nm_vpn_act_request_get_parent_dev (req));
return NULL;
}
......
......@@ -78,7 +78,7 @@ void nm_vpn_manager_dispose (NMVPNManager *manager)
g_return_if_fail (manager != NULL);
if (manager->act_req)
nm_vpn_manager_deactivate_vpn_connection (manager);
nm_vpn_manager_deactivate_vpn_connection (manager, nm_vpn_act_request_get_parent_dev (manager->act_req));
g_slist_foreach (manager->connections, (GFunc) nm_vpn_connection_unref, NULL);
g_slist_free (manager->connections);
......@@ -347,7 +347,7 @@ void nm_vpn_manager_activate_vpn_connection (NMVPNManager *manager, NMVPNConnect
g_return_if_fail (data_items != NULL);
if (manager->act_req)
nm_vpn_manager_deactivate_vpn_connection (manager);
nm_vpn_manager_deactivate_vpn_connection (manager, nm_vpn_act_request_get_parent_dev (manager->act_req));
service_name = nm_vpn_connection_get_service_name (vpn);
if (!(service = nm_vpn_manager_find_service_by_name (manager, service_name)))
......@@ -372,14 +372,14 @@ void nm_vpn_manager_activate_vpn_connection (NMVPNManager *manager, NMVPNConnect
* Signal the VPN service daemon to deactivate a particular VPN connection.
*
*/
void nm_vpn_manager_deactivate_vpn_connection (NMVPNManager *manager)
void nm_vpn_manager_deactivate_vpn_connection (NMVPNManager *manager, NMDevice *dev)
{
NMVPNService * service;
NMVPNConnection * vpn;
g_return_if_fail (manager != NULL);
if (!manager->act_req)
if (!manager->act_req || (dev != nm_vpn_act_request_get_parent_dev (manager->act_req)))
return;
if (nm_vpn_act_request_is_activating (manager->act_req) || nm_vpn_act_request_is_activated (manager->act_req))
......@@ -412,7 +412,7 @@ static gboolean nm_vpn_manager_vpn_activation_failed (gpointer user_data)
g_assert (manager);
if (manager->act_req == req)
nm_vpn_manager_deactivate_vpn_connection (manager);
nm_vpn_manager_deactivate_vpn_connection (manager, nm_vpn_act_request_get_parent_dev (req));
return FALSE;
}
......@@ -443,7 +443,7 @@ static gboolean nm_vpn_manager_vpn_connection_died (gpointer user_data)
g_assert (manager);
if (manager->act_req == req)
nm_vpn_manager_deactivate_vpn_connection (manager);
nm_vpn_manager_deactivate_vpn_connection (manager, nm_vpn_act_request_get_parent_dev (req));
return FALSE;
}
......
......@@ -36,7 +36,7 @@ NMVPNActRequest * nm_vpn_manager_get_vpn_act_request (NMVPNManager *manager);
void nm_vpn_manager_activate_vpn_connection (NMVPNManager *manager, NMVPNConnection *vpn, char **password_items,
int password_count, char **data_items, int data_count);
void nm_vpn_manager_deactivate_vpn_connection (NMVPNManager *manager);
void nm_vpn_manager_deactivate_vpn_connection (NMVPNManager *manager, NMDevice *dev);
NMVPNConnection * nm_vpn_manager_find_connection_by_name (NMVPNManager *manager, const char *con_name);
NMVPNService * nm_vpn_manager_find_service_by_name (NMVPNManager *manager, const char *service_name);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment