From d7bd32d03cec2303a135a4809170a1f4bd102ecc Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 22 Feb 2005 00:30:46 +0000 Subject: [PATCH] 2005-02-21 Dan Williams * src/NetworkManagerDHCP.[ch] - (nm_device_dhcp_remove_timeouts): new function * src/NetworkManagerDevice.c - Use nm_device_dhcp_remove_timeouts() everywhere that we need to remove the DHCP timeouts. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@466 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 9 +++++++++ src/NetworkManagerDHCP.c | 24 ++++++++++++++++++++++++ src/NetworkManagerDHCP.h | 1 + src/NetworkManagerDevice.c | 34 +++++----------------------------- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 31d90325af..2cabf2d39e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-02-21 Dan Williams + + * src/NetworkManagerDHCP.[ch] + - (nm_device_dhcp_remove_timeouts): new function + + * src/NetworkManagerDevice.c + - Use nm_device_dhcp_remove_timeouts() everywhere that we need to + remove the DHCP timeouts. + 2005-02-21 Dan Williams * panel-applet/NMWirelessApplet.[ch] diff --git a/src/NetworkManagerDHCP.c b/src/NetworkManagerDHCP.c index 6abc1796b2..78ec0e9a29 100644 --- a/src/NetworkManagerDHCP.c +++ b/src/NetworkManagerDHCP.c @@ -304,6 +304,30 @@ gboolean nm_device_dhcp_setup_timeouts (NMDevice *dev) } +/* + * nm_device_dhcp_remove_timeouts + * + * Remove the DHCP renew and rebind timeouts for a device. + * + */ +void nm_device_dhcp_remove_timeouts (NMDevice *dev) +{ + g_return_if_fail (dev != NULL); + + if (dev->renew_timeout > 0) + { + g_source_destroy (g_main_context_find_source_by_id (dev->context, dev->renew_timeout)); + dev->renew_timeout = 0; + } + if (dev->rebind_timeout > 0) + { + g_source_destroy (g_main_context_find_source_by_id (dev->context, dev->rebind_timeout)); + dev->renew_timeout = 0; + } + +} + + /* * nm_device_dhcp_renew * diff --git a/src/NetworkManagerDHCP.h b/src/NetworkManagerDHCP.h index 91ebb87db2..84d805fc19 100644 --- a/src/NetworkManagerDHCP.h +++ b/src/NetworkManagerDHCP.h @@ -27,6 +27,7 @@ int nm_device_dhcp_request (NMDevice *dev); void nm_device_dhcp_cease (NMDevice *dev); gboolean nm_device_dhcp_setup_timeouts (NMDevice *dev); +void nm_device_dhcp_remove_timeouts(NMDevice *dev); gboolean nm_device_dhcp_renew (gpointer user_data); gboolean nm_device_dhcp_rebind (gpointer user_data); gboolean nm_device_do_autoip (NMDevice *dev); diff --git a/src/NetworkManagerDevice.c b/src/NetworkManagerDevice.c index 0ac73367c7..27d6341af4 100644 --- a/src/NetworkManagerDevice.c +++ b/src/NetworkManagerDevice.c @@ -433,25 +433,9 @@ static gpointer nm_device_worker (gpointer user_data) g_main_loop_run (dev->loop); - if (nm_device_config_get_use_dhcp (dev)) - { - if (dev->renew_timeout > 0) - g_source_remove (dev->renew_timeout); - if (dev->rebind_timeout > 0) - g_source_remove (dev->rebind_timeout); - } - /* Remove any DHCP timeouts that might have been running */ - if (dev->renew_timeout) - { - g_source_remove (dev->renew_timeout); - dev->renew_timeout = 0; - } - if (dev->rebind_timeout) - { - g_source_remove (dev->rebind_timeout); - dev->rebind_timeout = 0; - } + if (nm_device_config_get_use_dhcp (dev)) + nm_device_dhcp_remove_timeouts (dev); g_main_loop_unref (dev->loop); g_main_context_unref (dev->context); @@ -2526,17 +2510,9 @@ gboolean nm_device_deactivate (NMDevice *dev, gboolean just_added) if (nm_device_get_driver_support_level (dev) == NM_DRIVER_UNSUPPORTED) return (TRUE); - /* Remove any DHCP timeouts we may have had running */ - if (dev->renew_timeout > 0) - { - g_source_remove (dev->renew_timeout); - dev->renew_timeout = 0; - } - if (dev->rebind_timeout > 0) - { - g_source_remove (dev->rebind_timeout); - dev->rebind_timeout = 0; - } + /* Remove any DHCP timeouts that might have been running */ + if (nm_device_config_get_use_dhcp (dev)) + nm_device_dhcp_remove_timeouts (dev); /* Take out any entries in the routing table and any IP address the device had. */ nm_system_device_flush_routes (dev);