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



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3669 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams
2008-05-14 14:01:59 +00:00
parent 2a2b75cc8b
commit 9d2475da06
3 changed files with 44 additions and 0 deletions

View File

@@ -66,6 +66,8 @@ typedef struct {
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 @@ finalize (GObject *object)
{
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 @@ nm_netlink_monitor_detach (NMNetlinkMonitor *monitor)
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 @@ nm_netlink_monitor_request_status (NMNetlinkMonitor *monitor,
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;
}