summary refs log tree commit diff
path: root/libnm-glib/nm-device.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2013-02-03 14:49:22 +0100
committerMichael Biebl <biebl@debian.org>2013-02-03 14:49:22 +0100
commit9c202e3e860b3be9e1f8882630b69affbb130102 (patch)
tree8202bf39f2129486971fa7d5ae0dee61a561aa53 /libnm-glib/nm-device.c
parent36cb2f364a821e1be50b23e03a18891ec55adb06 (diff)
Imported Upstream version 0.9.7.995 upstream/0.9.7.995
Diffstat (limited to 'libnm-glib/nm-device.c')
-rw-r--r--libnm-glib/nm-device.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/libnm-glib/nm-device.c b/libnm-glib/nm-device.c
index 865fc088..22e2844c 100644
--- a/libnm-glib/nm-device.c
+++ b/libnm-glib/nm-device.c
@@ -35,6 +35,7 @@
 #include "nm-device-wimax.h"
 #include "nm-device-infiniband.h"
 #include "nm-device-bond.h"
+#include "nm-device-bridge.h"
 #include "nm-device-vlan.h"
 #include "nm-device.h"
 #include "nm-device-private.h"
@@ -79,6 +80,7 @@ typedef struct {
 	NMIP6Config *ip6_config;
 	NMDHCP6Config *dhcp6_config;
 	NMDeviceState state;
+	NMDeviceState last_seen_state;
 	NMDeviceStateReason reason;
 
 	NMActiveConnection *active_connection;
@@ -196,10 +198,24 @@ device_state_change_reloaded (GObject *object,
                               gpointer user_data)
 {
 	NMDevice *self = NM_DEVICE (object);
+	NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
 	StateChangeData *data = user_data;
 
 	_nm_object_reload_properties_finish (NM_OBJECT (object), result, NULL);
 
+	/* If the device changes state several times in rapid succession, then we'll
+	 * queue several reload_properties() calls, and there's no guarantee that
+	 * they'll finish in the right order. In that case, only emit the signal
+	 * for the last one.
+	 */
+	if (priv->last_seen_state != data->new_state)
+		return;
+
+	/* Ensure that nm_device_get_state() will return the right value even if
+	 * we haven't processed the corresponding PropertiesChanged yet.
+	 */
+	priv->state = data->new_state;
+
 	g_signal_emit (self, signals[STATE_CHANGED], 0,
 	               data->new_state, data->old_state, data->reason);
 	g_slice_free (StateChangeData, data);
@@ -212,6 +228,9 @@ device_state_changed (DBusGProxy *proxy,
                       NMDeviceStateReason reason,
                       gpointer user_data)
 {
+	NMDevice *self = NM_DEVICE (user_data);
+	NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
+
 	if (old_state != new_state) {
 		StateChangeData *data;
 
@@ -220,6 +239,8 @@ device_state_changed (DBusGProxy *proxy,
 		 * in the process of asynchronously reading the new values.
 		 * Wait for that to finish before emitting the signal.
 		 */
+		priv->last_seen_state = new_state;
+
 		data = g_slice_new (StateChangeData);
 		data->old_state = old_state;
 		data->new_state = new_state;
@@ -252,6 +273,8 @@ _nm_device_gtype_from_dtype (NMDeviceType dtype)
 		return NM_TYPE_DEVICE_INFINIBAND;
 	case NM_DEVICE_TYPE_BOND:
 		return NM_TYPE_DEVICE_BOND;
+	case NM_DEVICE_TYPE_BRIDGE:
+		return NM_TYPE_DEVICE_BRIDGE;
 	case NM_DEVICE_TYPE_VLAN:
 		return NM_TYPE_DEVICE_VLAN;
 	default: