NetworkManager r3669 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3669 - in trunk: . src
- Date: Wed, 14 May 2008 15:02:00 +0100 (BST)
Author: dcbw
Date: Wed May 14 14:01:59 2008
New Revision: 3669
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3669&view=rev
Log:
2008-05-14 Dan Williams <dcbw redhat com>
Fix Linus' bug in rh #134886
* src/nm-device-802-3-ethernet.c
- (constructor): request initial carrier state
* src/nm-netlink-monitor.c
- (nm_netlink_monitor_request_status): schedule emission of carrier
signals after refilling the link cache. Because the refill is a
synchronous operation, the normal message hander won't get called
since libnl has already consumed the messages.
- (deferred_emit_carrier_state): emit carrier states from an idle handler
Modified:
trunk/ChangeLog
trunk/src/nm-device-802-3-ethernet.c
trunk/src/nm-netlink-monitor.c
Modified: trunk/src/nm-device-802-3-ethernet.c
==============================================================================
--- trunk/src/nm-device-802-3-ethernet.c (original)
+++ trunk/src/nm-device-802-3-ethernet.c Wed May 14 14:01:59 2008
@@ -274,6 +274,8 @@
caps = nm_device_get_capabilities (dev);
if (caps & NM_DEVICE_CAP_CARRIER_DETECT) {
+ GError *error = NULL;
+
/* Only listen to netlink for cards that support carrier detect */
NMNetlinkMonitor * monitor = nm_netlink_monitor_get ();
@@ -284,6 +286,11 @@
G_CALLBACK (nm_device_802_3_ethernet_carrier_off),
dev);
+ if (!nm_netlink_monitor_request_status (monitor, &error)) {
+ nm_warning ("couldn't request carrier state: %s", error->message);
+ g_error_free (error);
+ }
+
g_object_unref (monitor);
} else {
priv->link_connected_id = 0;
Modified: trunk/src/nm-netlink-monitor.c
==============================================================================
--- trunk/src/nm-netlink-monitor.c (original)
+++ trunk/src/nm-netlink-monitor.c Wed May 14 14:01:59 2008
@@ -66,6 +66,8 @@
GMainContext * context;
GIOChannel * io_channel;
GSource * event_source;
+
+ guint request_status_id;
} NMNetlinkMonitorPrivate;
static gboolean nm_netlink_monitor_event_handler (GIOChannel *channel,
@@ -115,6 +117,9 @@
{
NMNetlinkMonitorPrivate *priv = NM_NETLINK_MONITOR_GET_PRIVATE (object);
+ if (priv->request_status_id)
+ g_source_remove (priv->request_status_id);
+
if (priv->io_channel)
nm_netlink_monitor_close_connection (NM_NETLINK_MONITOR (object));
@@ -403,6 +408,19 @@
priv->context = NULL;
}
+static gboolean
+deferred_emit_carrier_state (gpointer user_data)
+{
+ NMNetlinkMonitor *monitor = NM_NETLINK_MONITOR (user_data);
+ NMNetlinkMonitorPrivate *priv = NM_NETLINK_MONITOR_GET_PRIVATE (monitor);
+
+ priv->request_status_id = 0;
+
+ /* Emit each device's new state */
+ nl_cache_foreach_filter (priv->nlh_link_cache, NULL, netlink_object_message_handler, monitor);
+ return FALSE;
+}
+
gboolean
nm_netlink_monitor_request_status (NMNetlinkMonitor *monitor,
GError **error)
@@ -414,11 +432,16 @@
priv = NM_NETLINK_MONITOR_GET_PRIVATE (monitor);
g_return_val_if_fail (priv->context != NULL, FALSE);
+ /* Update the link cache with latest state */
if (nl_cache_refill (priv->nlh, priv->nlh_link_cache)) {
nm_warning ("Error updating link cache: %s", nl_geterror ());
return FALSE;
}
+ /* Schedule the carrier state emission */
+ if (!priv->request_status_id)
+ priv->request_status_id = g_idle_add (deferred_emit_carrier_state, monitor);
+
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]