Skip to content

Commit

Permalink
shorter IPC paths
Browse files Browse the repository at this point in the history
fixes #20567
  • Loading branch information
joaomoreno committed Feb 14, 2017
1 parent 6bab393 commit 1d17b45
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/vs/platform/environment/node/environmentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,27 @@ function getUniqueUserId(): string {
return crypto.createHash('sha256').update(username).digest('hex').substr(0, 6);
}

function getIPCHandlePrefix(nixBaseDir: string = os.tmpdir()): string {
let name = pkg.name;
function getNixIPCHandle(userDataPath: string, type: string): string {
return path.join(userDataPath, `${pkg.version}-${type}.sock`);
}

function getWin32IPCHandle(type: string): string {
// Support to run VS Code multiple times as different user
// by making the socket unique over the logged in user
let userId = getUniqueUserId();
if (userId) {
name += `-${userId}`;
}
const userId = getUniqueUserId();
const name = product.applicationName + (userId ? `-${userId}` : '');

return `\\\\.\\pipe\\${name}-${pkg.version}-${type}-sock`;
}

function getIPCHandle(userDataPath: string, type: string): string {
if (process.platform === 'win32') {
return `\\\\.\\pipe\\${name}`;
return getWin32IPCHandle(type);
} else {
return path.join(nixBaseDir, name);
return getNixIPCHandle(userDataPath, type);
}
}

function getIPCHandleSuffix(): string {
return process.platform === 'win32' ? '-sock' : '.sock';
}

export class EnvironmentService implements IEnvironmentService {

_serviceBrand: any;
Expand Down Expand Up @@ -113,10 +113,10 @@ export class EnvironmentService implements IEnvironmentService {
get logExtensionHostCommunication(): boolean { return this._args.logExtensionHostCommunication; }

@memoize
get mainIPCHandle(): string { return `${getIPCHandlePrefix(this.userDataPath)}-${pkg.version}${getIPCHandleSuffix()}`; }
get mainIPCHandle(): string { return getIPCHandle(this.userDataPath, 'main'); }

@memoize
get sharedIPCHandle(): string { return `${getIPCHandlePrefix(this.userDataPath)}-${pkg.version}-shared${getIPCHandleSuffix()}`; }
get sharedIPCHandle(): string { return getIPCHandle(this.userDataPath, 'shared'); }

@memoize
get nodeCachedDataDir(): string { return path.join(this.userDataPath, 'CachedData'); }
Expand Down

0 comments on commit 1d17b45

Please sign in to comment.