Bug 986365 - Crash in supplicant because of closing supplicant while waiting for event. r=chulee, a=1.3+
authorVincent Chang <vchang@mozilla.com>
Thu, 27 Mar 2014 13:58:04 +0800
changeset 192706 d64cb907cb9c38432a4feb016138268704dbd1eb
parent 192705 35dee6eb122050db69d2090d3c85685a0112ece3
child 192707 9aa8010a173ac52f791c9b76c96a70553adfdb84
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschulee, 1
bugs986365
milestone30.0a2
Bug 986365 - Crash in supplicant because of closing supplicant while waiting for event. r=chulee, a=1.3+
dom/wifi/WifiWorker.js
--- a/dom/wifi/WifiWorker.js
+++ b/dom/wifi/WifiWorker.js
@@ -742,16 +742,18 @@ var WifiManager = (function() {
       // 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
       // unexpected condition, we should notify supplicant lost here.
       if (manager.state !== "DISABLING" && manager.state !== "UNINITIALIZED") {
         notify("supplicantlost", { success: true });
       }
+      wifiCommand.closeSupplicantConnection(function() {
+      });
       return false;
     }
     if (eventData.indexOf("CTRL-EVENT-DISCONNECTED") === 0) {
       var token = event.split(" ")[1];
       var bssid = token.split("=")[1];
       if (manager.authenticationFailuresCount > MAX_RETRIES_ON_AUTHENTICATION_FAILURE) {
         manager.authenticationFailuresCount = 0;
         notify("disconnected", {ssid: manager.connectionInfo.ssid});
@@ -946,29 +948,27 @@ var WifiManager = (function() {
               createWaitForDriverReadyTimer(doStartSupplicant);
             } else {
               doStartSupplicant();
             }
           });
         });
       });
     } else {
+      manager.state = "DISABLING";
       // Note these following calls ignore errors. If we fail to kill the
       // supplicant gracefully, then we need to continue telling it to die
       // until it does.
       let doDisableWifi = function() {
-        manager.state = "DISABLING";
         wifiCommand.terminateSupplicant(function (ok) {
           manager.connectionDropped(function () {
             wifiCommand.stopSupplicant(function (status) {
-              wifiCommand.closeSupplicantConnection(function () {
-                manager.state = "UNINITIALIZED";
-                netUtil.disableInterface(manager.ifname, function (ok) {
-                  unloadDriver(WIFI_FIRMWARE_STATION, callback);
-                });
+              manager.state = "UNINITIALIZED";
+              netUtil.disableInterface(manager.ifname, function (ok) {
+                unloadDriver(WIFI_FIRMWARE_STATION, callback);
               });
             });
           });
         });
       }
 
       if (p2pSupported) {
         p2pManager.setEnabled(false, { onDisabled: doDisableWifi });
@@ -1297,17 +1297,17 @@ var WifiManager = (function() {
 
   manager.getP2pManager = function() {
     return p2pManager;
   };
 
   manager.enableP2p = function(callback) {
     p2pManager.setEnabled(true, {
       onSupplicantConnected: function() {
-        wifiService.waitForEvent(WifiP2pManager.INTERFACE_NAME);
+        waitForEvent(WifiP2pManager.INTERFACE_NAME);
       },
 
       onEnabled: function(success) {
         callback(success);
       }
     });
   };