mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Fix a listener in tunnel service that's GC'ed without having been disposed (#214138)
This commit is contained in:
parent
6908956c15
commit
8dd604a8d8
|
@ -5,7 +5,7 @@
|
|||
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { OperatingSystem } from 'vs/base/common/platform';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
|
@ -215,7 +215,7 @@ export class DisposableTunnel {
|
|||
}
|
||||
}
|
||||
|
||||
export abstract class AbstractTunnelService implements ITunnelService {
|
||||
export abstract class AbstractTunnelService extends Disposable implements ITunnelService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
private _onTunnelOpened: Emitter<RemoteTunnel> = new Emitter();
|
||||
|
@ -234,7 +234,7 @@ export abstract class AbstractTunnelService implements ITunnelService {
|
|||
public constructor(
|
||||
@ILogService protected readonly logService: ILogService,
|
||||
@IConfigurationService protected readonly configurationService: IConfigurationService
|
||||
) { }
|
||||
) { super(); }
|
||||
|
||||
get hasTunnelProvider(): boolean {
|
||||
return !!this._tunnelProvider;
|
||||
|
@ -308,7 +308,8 @@ export abstract class AbstractTunnelService implements ITunnelService {
|
|||
return tunnels;
|
||||
}
|
||||
|
||||
async dispose(): Promise<void> {
|
||||
override async dispose(): Promise<void> {
|
||||
super.dispose();
|
||||
for (const portMap of this._tunnels.values()) {
|
||||
for (const { value } of portMap.values()) {
|
||||
await value.then(tunnel => typeof tunnel !== 'string' ? tunnel?.dispose() : undefined);
|
||||
|
|
|
@ -68,11 +68,11 @@ export class TunnelService extends AbstractTunnelService {
|
|||
super(logService, configurationService);
|
||||
|
||||
// Destroy any shared process tunnels that might still be active
|
||||
lifecycleService.onDidShutdown(() => {
|
||||
this._register(lifecycleService.onDidShutdown(() => {
|
||||
this._activeSharedProcessTunnels.forEach((id) => {
|
||||
this._sharedProcessTunnelService.destroyTunnel(id);
|
||||
});
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public isPortPrivileged(port: number): boolean {
|
||||
|
|
Loading…
Reference in a new issue