зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1469054 - Make check() in adb-running-checker fail if a certain period of time elapsed. r=jdescottes
On MacOSX connecting to a port which is not started listening gets stuck
(bug 1481963
), to avoid the stuck, we make forcibly the function fail.
MozReview-Commit-ID: COVplVPx3vA
--HG--
extra : rebase_source : 2f048e8e8aa7e9b9212c6cfa31f3589b73e0087c
This commit is contained in:
Родитель
cc02c63e27
Коммит
e061017292
|
@ -15,10 +15,25 @@ const client = require("./adb-client");
|
|||
exports.check = async function check() {
|
||||
let socket;
|
||||
let state;
|
||||
let timerID;
|
||||
const TIMEOUT_TIME = 1000;
|
||||
|
||||
console.debug("Asking for host:version");
|
||||
|
||||
return new Promise(resolve => {
|
||||
// On MacOSX connecting to a port which is not started listening gets
|
||||
// stuck (bug 1481963), to avoid the stuck, we do forcibly fail the
|
||||
// connection after |TIMEOUT_TIME| elapsed.
|
||||
timerID = setTimeout(() => {
|
||||
socket.close();
|
||||
resolve(false);
|
||||
}, TIMEOUT_TIME);
|
||||
|
||||
function finish(returnValue) {
|
||||
clearTimeout(timerID);
|
||||
resolve(returnValue);
|
||||
}
|
||||
|
||||
const runFSM = function runFSM(packetData) {
|
||||
console.debug("runFSM " + state);
|
||||
switch (state) {
|
||||
|
@ -35,22 +50,22 @@ exports.check = async function check() {
|
|||
socket.close();
|
||||
const version = parseInt(data, 16);
|
||||
if (version >= 31) {
|
||||
resolve(true);
|
||||
finish(true);
|
||||
} else {
|
||||
console.log("killing existing adb as we need version >= 31");
|
||||
resolve(false);
|
||||
finish(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
console.debug("Unexpected State: " + state);
|
||||
resolve(false);
|
||||
finish(false);
|
||||
}
|
||||
};
|
||||
|
||||
const setupSocket = function() {
|
||||
socket.s.onerror = function(event) {
|
||||
console.debug("running checker onerror");
|
||||
resolve(false);
|
||||
finish(false);
|
||||
};
|
||||
|
||||
socket.s.onopen = function(event) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче