提交 e023d81c 编写于 作者: J Joao Moreno

ipc: send client ids when connecting

上级 3650ea42
......@@ -207,9 +207,9 @@ export function serve(hook: any): TPromise<Server> {
});
}
export function connect(port: number, clientId?: string): TPromise<Client>;
export function connect(namedPipe: string, clientId?: string): TPromise<Client>;
export function connect(hook: any, clientId: string = ''): TPromise<Client> {
export function connect(port: number, clientId: string): TPromise<Client>;
export function connect(namedPipe: string, clientId: string): TPromise<Client>;
export function connect(hook: any, clientId: string): TPromise<Client> {
return new TPromise<Client>((c, e) => {
const socket = createConnection(hook, () => {
socket.removeListener('error', e);
......
......@@ -237,7 +237,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
}
// there's a running instance, let's connect to it
return connect(environmentService.mainIPCHandle).then(
return connect(environmentService.mainIPCHandle, 'main').then(
client => {
// Tests from CLI require to be the only instance currently (TODO@Ben support multiple instances and output)
......
......@@ -122,7 +122,7 @@ function setupIPC(hook: string): TPromise<Server> {
// should retry, not windows and eaddrinuse
return connect(hook).then(
return connect(hook, '').then(
client => {
// we could connect to a running instance. this is not good, abort
client.dispose();
......
......@@ -211,16 +211,6 @@ export class WorkbenchShell {
private initServiceCollection(container: HTMLElement): [InstantiationService, ServiceCollection] {
const disposables = new Disposables();
const sharedProcess = connectNet(this.environmentService.sharedIPCHandle);
sharedProcess.done(client => {
client.onClose(() => {
this.messageService.show(Severity.Error, {
message: nls.localize('sharedProcessCrashed', "The shared process terminated unexpectedly. Please reload the window to recover."),
actions: [instantiationService.createInstance(ReloadWindowAction, ReloadWindowAction.ID, ReloadWindowAction.LABEL)]
});
});
}, errors.onUnexpectedError);
const mainProcessClient = new ElectronIPCClient(ipcRenderer);
disposables.add(mainProcessClient);
......@@ -235,6 +225,16 @@ export class WorkbenchShell {
this.windowService = instantiationService.createInstance(WindowService);
serviceCollection.set(IWindowService, this.windowService);
const sharedProcess = connectNet(this.environmentService.sharedIPCHandle, `window:${ this.windowService.getWindowId() }`);
sharedProcess.done(client => {
client.onClose(() => {
this.messageService.show(Severity.Error, {
message: nls.localize('sharedProcessCrashed', "The shared process terminated unexpectedly. Please reload the window to recover."),
actions: [instantiationService.createInstance(ReloadWindowAction, ReloadWindowAction.ID, ReloadWindowAction.LABEL)]
});
});
}, errors.onUnexpectedError);
// Storage
const disableWorkspaceStorage = this.environmentService.extensionTestsPath || (!this.workspace && !this.environmentService.extensionDevelopmentPath); // without workspace or in any extension test, we use inMemory storage unless we develop an extension where we want to preserve state
this.storageService = instantiationService.createInstance(Storage, window.localStorage, disableWorkspaceStorage ? inMemoryLocalStorageInstance : window.localStorage);
......
......@@ -104,7 +104,7 @@ function connectToRenderer(): TPromise<IRendererConnection> {
}
function connectToSharedProcess(): TPromise<Client> {
return connect(process.env['VSCODE_SHARED_IPC_HOOK']);
return connect(process.env['VSCODE_SHARED_IPC_HOOK'], `extensionHost:${ process.env['VSCODE_WINDOW_ID'] }`);
}
TPromise.join<any>([connectToRenderer(), connectToSharedProcess()])
......
......@@ -36,7 +36,7 @@ function main(argv: string[]): void {
var request = argv[2];
var host = argv[4].substring(1, argv[4].length - 2);
connect(process.env['VSCODE_IPC_HOOK'])
connect(process.env['VSCODE_IPC_HOOK'], 'askpass')
.then(client => {
const channel = client.getChannel<IAskpassChannel>('askpass');
const service = new AskpassChannelClient(channel);
......
......@@ -123,7 +123,12 @@ class ExtensionHostProcessManager {
public startExtensionHostProcess(onExtensionHostMessage: (msg: any) => void): void {
let opts: any = {
env: objects.mixin(objects.clone(process.env), { AMD_ENTRYPOINT: 'vs/workbench/node/extensionHostProcess', PIPE_LOGGING: 'true', VERBOSE_LOGGING: true })
env: objects.mixin(objects.clone(process.env), {
AMD_ENTRYPOINT: 'vs/workbench/node/extensionHostProcess',
PIPE_LOGGING: 'true',
VERBOSE_LOGGING: true,
VSCODE_WINDOW_ID: String(this.windowService.getWindowId())
})
};
// Help in case we fail to start it
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册