mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 01:25:37 -05:00
Fix some connection listener leaks (#6357)
* Fix some connection listener leaks * More descriptive name and update summary * Dispose some more connections and fix a few spelling errors
This commit is contained in:
@@ -55,7 +55,7 @@ export interface ICapabilitiesService {
|
||||
isFeatureAvailable(action: IAction, connectionManagementInfo: ConnectionManagementInfo): boolean;
|
||||
|
||||
/**
|
||||
* When a new capabilities is registered, it emits the provider name, be to use to get the new capabilities
|
||||
* When new capabilities are registered, it emits the @see ProviderFeatures, which can be used to get the new capabilities
|
||||
*/
|
||||
readonly onCapabilitiesRegistered: Event<ProviderFeatures>;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ interface CapabilitiesMomento {
|
||||
|
||||
/**
|
||||
* Capabilities service implementation class. This class provides the ability
|
||||
* to discover the DMP capabilties that a DMP provider offers.
|
||||
* to discover the DMP capabilities that a DMP provider offers.
|
||||
*/
|
||||
export class CapabilitiesService extends Disposable implements ICapabilitiesService {
|
||||
_serviceBrand: any;
|
||||
@@ -50,7 +50,7 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
||||
constructor(
|
||||
@IStorageService private _storageService: IStorageService,
|
||||
@IExtensionService extensionService: IExtensionService,
|
||||
@IExtensionManagementService extentionManagementService: IExtensionManagementService
|
||||
@IExtensionManagementService extensionManagementService: IExtensionManagementService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -78,7 +78,7 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
|
||||
|
||||
_storageService.onWillSaveState(() => this.shutdown());
|
||||
|
||||
this._register(extentionManagementService.onDidUninstallExtension(({ identifier }) => {
|
||||
this._register(extensionManagementService.onDidUninstallExtension(({ identifier }) => {
|
||||
const connectionProvider = 'connectionProvider';
|
||||
extensionService.getExtensions().then(i => {
|
||||
let extension = i.find(c => c.identifier.value.toLowerCase() === identifier.id.toLowerCase());
|
||||
|
||||
@@ -691,7 +691,10 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
}
|
||||
|
||||
public hasRegisteredServers(): boolean {
|
||||
return this.doHasRegisteredServers(this.getConnectionGroups());
|
||||
const groups: ConnectionProfileGroup[] = this.getConnectionGroups();
|
||||
const hasRegisteredServers: boolean = this.doHasRegisteredServers(groups);
|
||||
groups.forEach(cpg => cpg.dispose());
|
||||
return hasRegisteredServers;
|
||||
}
|
||||
|
||||
private doHasRegisteredServers(root: ConnectionProfileGroup[]): boolean {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
|
||||
export interface IConnectionProfileGroup {
|
||||
id: string;
|
||||
@@ -13,7 +14,7 @@ export interface IConnectionProfileGroup {
|
||||
description: string;
|
||||
}
|
||||
|
||||
export class ConnectionProfileGroup implements IConnectionProfileGroup {
|
||||
export class ConnectionProfileGroup extends Disposable implements IConnectionProfileGroup {
|
||||
|
||||
public children: ConnectionProfileGroup[];
|
||||
public connections: ConnectionProfile[];
|
||||
@@ -26,6 +27,7 @@ export class ConnectionProfileGroup implements IConnectionProfileGroup {
|
||||
public color: string,
|
||||
public description: string
|
||||
) {
|
||||
super();
|
||||
this.parentId = parent ? parent.id : undefined;
|
||||
if (this.name === ConnectionProfileGroup.RootGroupName) {
|
||||
this.name = '';
|
||||
@@ -100,9 +102,8 @@ export class ConnectionProfileGroup implements IConnectionProfileGroup {
|
||||
}
|
||||
}
|
||||
|
||||
public getChildren(): any {
|
||||
let allChildren = [];
|
||||
|
||||
public getChildren(): (ConnectionProfile | ConnectionProfileGroup)[] {
|
||||
let allChildren: (ConnectionProfile | ConnectionProfileGroup)[] = [];
|
||||
if (this.connections) {
|
||||
this.connections.forEach((conn) => {
|
||||
allChildren.push(conn);
|
||||
@@ -131,6 +132,7 @@ export class ConnectionProfileGroup implements IConnectionProfileGroup {
|
||||
connections.forEach((conn) => {
|
||||
this.connections = this.connections.filter((curConn) => { return curConn.id !== conn.id; });
|
||||
conn.parent = this;
|
||||
this._register(conn);
|
||||
this.connections.push(conn);
|
||||
});
|
||||
|
||||
@@ -143,6 +145,7 @@ export class ConnectionProfileGroup implements IConnectionProfileGroup {
|
||||
groups.forEach((group) => {
|
||||
this.children = this.children.filter((grp) => { return group.id !== grp.id; });
|
||||
group.parent = this;
|
||||
this._register(group);
|
||||
this.children.push(group);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { Disposable, dispose, IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { isString } from 'vs/base/common/types';
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
@@ -19,6 +19,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
options: { [name: string]: any } = {};
|
||||
|
||||
private _providerName: string;
|
||||
private _onCapabilitiesRegisteredDisposable: IDisposable;
|
||||
protected _serverCapabilities: ConnectionProviderProperties;
|
||||
private static readonly SqlAuthentication = 'SqlLogin';
|
||||
public static readonly ProviderPropertyName = 'providerName';
|
||||
@@ -74,14 +75,24 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
|
||||
if (capabilities) {
|
||||
this._serverCapabilities = capabilities.connection;
|
||||
}
|
||||
this._register(this.capabilitiesService.onCapabilitiesRegistered(e => {
|
||||
if (this._onCapabilitiesRegisteredDisposable) {
|
||||
dispose(this._onCapabilitiesRegisteredDisposable);
|
||||
}
|
||||
this._onCapabilitiesRegisteredDisposable = this.capabilitiesService.onCapabilitiesRegistered(e => {
|
||||
if (e.connection.providerId === this.providerName) {
|
||||
this._serverCapabilities = e.connection;
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
if (this._onCapabilitiesRegisteredDisposable) {
|
||||
dispose(this._onCapabilitiesRegisteredDisposable);
|
||||
}
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public clone(): ProviderConnectionInfo {
|
||||
let instance = new ProviderConnectionInfo(this.capabilitiesService, this.providerName);
|
||||
instance.options = Object.assign({}, this.options);
|
||||
|
||||
Reference in New Issue
Block a user