Bug 999391 - [Wifi] CTRL-EVENT-TERMINATING with recv errors message is not handled correctly. r=chulee
authorVincent Chang <vchang@mozilla.com>
Tue, 22 Apr 2014 20:22:03 +0800
changeset 180619 a60aa2d95896057da9b3ec89af8ee51528a3d99d
parent 180618 1778e4c2abd79f78f8caa257672b462901dbd7cc
child 180620 92b550d8a1118b2af2e4fbe63d6ccc233dfac6f2
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewerschulee
bugs999391
milestone31.0a1
Bug 999391 - [Wifi] CTRL-EVENT-TERMINATING with recv errors message is not handled correctly. r=chulee
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -553,16 +553,17 @@ var WifiManager = (function() {
   // try to connect to the supplicant
   var connectTries = 0;
   var retryTimer = null;
   function connectCallback(ok) {
     if (ok === 0) {
       // Tell the event worker to start waiting for events.
       retryTimer = null;
       connectTries = 0;
+      recvErrors = 0;
       manager.connectToSupplicant = true;
       didConnectSupplicant(function(){});
       return;
     }
     if (connectTries++ < 5) {
       // Try again in 1 seconds.
       if (!retryTimer)
         retryTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
@@ -730,18 +731,18 @@ var WifiManager = (function() {
       var handlerName = driverEventMap[eventData];
       if (handlerName)
         notify(handlerName);
       return true;
     }
     if (eventData.indexOf("CTRL-EVENT-TERMINATING") === 0) {
       // As long the monitor socket is not closed and we haven't seen too many
       // recv errors yet, we will keep going for a bit longer.
-      if (eventData.indexOf("connection closed") === -1 &&
-          eventData.indexOf("recv error") !== -1 && ++recvErrors < 10)
+      if (event.indexOf("connection closed") === -1 &&
+          event.indexOf("recv error") !== -1 && ++recvErrors < 10)
         return true;
 
       notifyStateChange({ state: "DISCONNECTED", BSSID: null, id: -1 });
 
       // If the supplicant is terminated as commanded, the supplicant lost
       // notification will be sent after driver unloaded. In such case, the
       // manager state will be "DISABLING" or "UNINITIALIZED".
       // So if supplicant terminated with incorrect manager state, implying