Bug 1167466 - Prevent from previous failed DHCP callback interferring ongoing DHCP request. r=vchang.
authorhchang <hchang@mozilla.com>
Mon, 08 Jun 2015 23:42:00 +0200
changeset 279210 475a5b2d58dba883df289549adf23dc9ffb2d107
parent 279209 b0b70cfa50f0a2f44bc48cbc3b5cd970c6c7845a
child 279211 4a91e5fda5e28f497bdcf2ed1d79c8abf92f8a8b
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvchang
bugs1167466
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1167466 - Prevent from previous failed DHCP callback interferring ongoing DHCP request. r=vchang.
dom/wifi/WifiNetUtil.jsm
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiNetUtil.jsm
+++ b/dom/wifi/WifiNetUtil.jsm
@@ -25,20 +25,22 @@ this.WifiNetUtil = function(controlMessa
   function debug(msg) {
     if (DEBUG) {
       dump('-------------- NetUtil: ' + msg);
     }
   }
 
   var util = {};
 
-  util.runDhcp = function (ifname, callback) {
+  util.runDhcp = function (ifname, gen, callback) {
     util.stopDhcp(ifname, function() {
       gNetworkService.dhcpRequest(ifname, function(success, dhcpInfo) {
-        util.runIpConfig(ifname, dhcpInfo, callback);
+        util.runIpConfig(ifname, dhcpInfo, function(data) {
+          callback(data, gen);
+        });
       });
     });
   };
 
   util.stopDhcp = function (ifname, callback) {
     // This function does exactly what dhcp_stop does. Unforunately, if we call
     // this function twice before the previous callback is returned. We may block
     // our self waiting for the callback. It slows down the wifi startup procedure.
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -632,34 +632,41 @@ var WifiManager = (function() {
     });
   }
 
   manager.start = function() {
     debug("detected SDK version " + sdkVersion);
     wifiCommand.connectToSupplicant(connectCallback);
   }
 
+  let dhcpRequestGen = 0;
+
   function onconnected() {
     // For now we do our own DHCP. In the future, this should be handed
     // off to the Network Manager.
     let currentNetwork = Object.create(null);
     currentNetwork.netId = manager.connectionInfo.id;
 
     manager.getNetworkConfiguration(currentNetwork, function (){
       let key = getNetworkKey(currentNetwork);
       if (staticIpConfig  &&
           (key in staticIpConfig) &&
           staticIpConfig[key].enabled) {
           debug("Run static ip");
           runStaticIp(manager.ifname, key);
           return;
       }
-      netUtil.runDhcp(manager.ifname, function(data) {
+      netUtil.runDhcp(manager.ifname, dhcpRequestGen++, function(data, gen) {
         dhcpInfo = data.info;
+        debug('dhcpRequestGen: ' + dhcpRequestGen + ', gen: ' + gen);
         if (!dhcpInfo) {
+          if (gen + 1 < dhcpRequestGen) {
+            debug('Do not bother younger DHCP request.');
+            return;
+          }
           if (++manager.dhcpFailuresCount >= MAX_RETRIES_ON_DHCP_FAILURE) {
             manager.dhcpFailuresCount = 0;
             notify("disconnected", {connectionInfo: manager.connectionInfo});
             return;
           }
           // NB: We have to call disconnect first. Otherwise, we only reauth with
           // the existing AP and don't retrigger DHCP.
           manager.disconnect(function() {