Bug 1210370 - Close wpa_supplicant before we shutdown nsIWifiProxyService. r=mrbkap

This commit is contained in:
hchang 2015-10-06 09:55:01 +08:00
parent f447a8f2b7
commit 6b5f0c2e9b
2 changed files with 24 additions and 6 deletions

View File

@ -248,6 +248,10 @@ WifiProxyService::SendCommand(JS::Handle<JS::Value> aOptions,
return NS_ERROR_FAILURE;
}
if (!mControlThread) {
return NS_ERROR_FAILURE;
}
// Dispatch the command to the control thread.
CommandOptions commandOptions(options);
nsCOMPtr<nsIRunnable> runnable = new ControlRunnable(commandOptions, aInterface);
@ -293,8 +297,10 @@ WifiProxyService::DispatchWifiResult(const WifiResultOptions& aOptions, const ns
return;
}
// Call the listener with a JS value.
mListener->OnCommand(val, aInterface);
if (mListener) {
// Call the listener with a JS value.
mListener->OnCommand(val, aInterface);
}
}
void

View File

@ -1432,6 +1432,14 @@ var WifiManager = (function() {
? wifiCommand.getConnectionInfoICS
: wifiCommand.getConnectionInfoGB;
manager.ensureSupplicantDetached = aCallback => {
if (!manager.enabled) {
aCallback();
return;
}
wifiCommand.closeSupplicantConnection(aCallback);
};
manager.isHandShakeState = function(state) {
switch (state) {
case "AUTHENTICATING":
@ -3820,10 +3828,14 @@ WifiWorker.prototype = {
break;
case "xpcom-shutdown":
let wifiService = Cc["@mozilla.org/wifi/service;1"].getService(Ci.nsIWifiProxyService);
wifiService.shutdown();
let wifiCertService = Cc["@mozilla.org/wifi/certservice;1"].getService(Ci.nsIWifiCertService);
wifiCertService.shutdown();
// Ensure the supplicant is detached from B2G to avoid XPCOM shutdown
// blocks forever.
WifiManager.ensureSupplicantDetached(() => {
let wifiService = Cc["@mozilla.org/wifi/service;1"].getService(Ci.nsIWifiProxyService);
wifiService.shutdown();
let wifiCertService = Cc["@mozilla.org/wifi/certservice;1"].getService(Ci.nsIWifiCertService);
wifiCertService.shutdown();
});
break;
}
},