Fix RPC handler race condition causing a crash (#2940)

Fixes #2861
This commit is contained in:
Justin Lowery 2018-05-10 02:20:59 -04:00 committed by CHaBou
parent 64ec145b55
commit f72093c9d7

View file

@ -127,9 +127,6 @@ module.exports = class Window {
const session = sessions.get(uid);
if (session) {
session.exit();
} else {
//eslint-disable-next-line no-console
console.log('session not found by', uid);
}
});
rpc.on('unmaximize', () => {
@ -143,11 +140,13 @@ module.exports = class Window {
});
rpc.on('resize', ({uid, cols, rows}) => {
const session = sessions.get(uid);
if (session) {
session.resize({cols, rows});
}
});
rpc.on('data', ({uid, data, escaped}) => {
const session = sessions.get(uid);
if (session) {
if (escaped) {
const escapedData = session.shell.endsWith('cmd.exe')
? `"${data}"` // This is how cmd.exe does it
@ -157,6 +156,7 @@ module.exports = class Window {
} else {
session.write(data);
}
}
});
rpc.on('open external', ({url}) => {
shell.openExternal(url);