From 53e50a9c7ed8fc00b9be2ae23ae3393351f2854a Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sun, 12 Sep 2004 15:39:05 +0000 Subject: [PATCH] 2004-09-11 Dan Williams * src/NetworkManager.c - Fix race condition between initscripts and NM on card insertion which could cause a card to keep an IP address and routes around even when it was not the active device * src/NetworkManagerDbus.c - Fix compile errors, free more DBusErrors git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@154 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 10 ++++++++++ src/NetworkManager.c | 12 ++++++++++++ src/NetworkManagerDbus.c | 10 ++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a83fdaa86e..3e6480345b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-09-11 Dan Williams + + * src/NetworkManager.c + - Fix race condition between initscripts and NM on card insertion + which could cause a card to keep an IP address and routes around + even when it was not the active device + + * src/NetworkManagerDbus.c + - Fix compile errors, free more DBusErrors + 2004-09-11 Dan Williams * docs/NetworkManager DBUS API.txt diff --git a/src/NetworkManager.c b/src/NetworkManager.c index d1bfff2d06..92a575838a 100644 --- a/src/NetworkManager.c +++ b/src/NetworkManager.c @@ -372,6 +372,18 @@ gboolean nm_link_state_monitor (gpointer user_data) */ nm_device_update_ip4_address (dev); } + else + { + /* Ensure that the device has no IP address or routes. This will + * sometimes occur when a card gets inserted, and the system + * initscripts will run to bring the card up, but they get around to + * running _after_ we've been notified of insertion and cleared out + * card info already. + */ + nm_system_device_flush_routes (dev); + if (nm_device_get_ip4_address (dev) != 0) + nm_system_device_flush_addresses (dev); + } } element = g_slist_next (element); diff --git a/src/NetworkManagerDbus.c b/src/NetworkManagerDbus.c index 051b7b471c..5576878ef9 100644 --- a/src/NetworkManagerDbus.c +++ b/src/NetworkManagerDbus.c @@ -1396,11 +1396,11 @@ DBusConnection *nm_dbus_init (NMData *data) dbus_error_init (&dbus_error); connection = dbus_bus_get (DBUS_BUS_SYSTEM, &dbus_error); - if ((connection == NULL) || dbus_error_is_set (&error)) + if ((connection == NULL) || dbus_error_is_set (&dbus_error)) { syslog (LOG_ERR, "nm_dbus_init() could not get the system bus. Make sure the message bus daemon is running?"); - if (dbus_error_is_set (&error)) - dbus_error_free (&error); + if (dbus_error_is_set (&dbus_error)) + dbus_error_free (&dbus_error); return (NULL); } @@ -1430,18 +1430,20 @@ DBusConnection *nm_dbus_init (NMData *data) "sender='" NMI_DBUS_SERVICE "'," "path='" NMI_DBUS_PATH "'", &dbus_error); + dbus_error_free (&dbus_error); dbus_bus_add_match(connection, "type='signal'," "interface='" DBUS_INTERFACE_ORG_FREEDESKTOP_DBUS "'," "sender='" DBUS_SERVICE_ORG_FREEDESKTOP_DBUS "'", &dbus_error); + dbus_error_free (&dbus_error); dbus_bus_acquire_service (connection, NM_DBUS_SERVICE, 0, &dbus_error); if (dbus_error_is_set (&dbus_error)) { syslog (LOG_ERR, "nm_dbus_init() could not acquire its service. dbus_bus_acquire_service() says: '%s'", dbus_error.message); - dbus_error_free (&error); + dbus_error_free (&dbus_error); return (NULL); }