diff options
author | Daniel Drake <dsd@laptop.org> | 2008-09-04 16:47:47 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2008-09-08 15:50:59 (GMT) |
commit | 7caab7ee929b7692108b5e28d47884a133aa18fa (patch) | |
tree | 289fdf9aad4ba64877cb3f98b75bb87dd2c349b3 | |
parent | 776c92476e18788e415f8c04b1f6aadbf0b4990e (diff) |
Avoid network_appeared race
This prevents access points being shown twice (#7415). See the comments
in the patch for explanation.
It is perhaps questioanable why NetworkManager is producing
NetworkAppeared messages at this time, but it doesn't seem worth the
effort digging into that side of things given that we will soon be
upgrading to NetworkManager-0.7 which will totally shake up this code
anyway.
-rw-r--r-- | src/hardware/nmclient.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/hardware/nmclient.py b/src/hardware/nmclient.py index ac9ddfd..c517391 100644 --- a/src/hardware/nmclient.py +++ b/src/hardware/nmclient.py @@ -392,6 +392,18 @@ class Device(gobject.GObject): self.emit('strength-changed') def network_appeared(self, network): + # NM may emit NetworkAppeared messages before the initialization-time + # getProperties call completes. This means that we are in danger of + # instantiating the "appeared" network here, and then instantiating + # the same network later on when getProperties completes + # (_update_reply_cb calls _update_networks). + # We avoid this race by confirming that getProperties has completed + # before listening to any NetworkAppeared messages. We assume that + # any networks that get reported as appeared in this race window + # will be included in the getProperties response. + if not self._valid: + return + if self._networks.has_key(network): return net = Network(self._client, network) |