mirror of https://github.com/grpc/grpc-node.git
fix: cancel the cleanup task inside the unrefUnusedSubchannels function
This commit is contained in:
parent
93f8169139
commit
5f271de8c2
|
@ -289,7 +289,7 @@ export class ChannelImplementation implements Channel {
|
|||
this.resolvingLoadBalancer.destroy();
|
||||
this.updateState(ConnectivityState.SHUTDOWN);
|
||||
|
||||
this.subchannelPool.forceCleanup();
|
||||
this.subchannelPool.unrefUnusedSubchannels();
|
||||
}
|
||||
|
||||
getTarget() {
|
||||
|
|
|
@ -55,7 +55,7 @@ export class SubchannelPool {
|
|||
*
|
||||
* @returns `true` if all subchannels have been unrefed. `false` otherwise.
|
||||
*/
|
||||
unrefUnusedSubchannels(): boolean {
|
||||
unrefUnusedSubchannels(): void {
|
||||
let allSubchannelsUnrefed = true;
|
||||
|
||||
/* These objects are created with Object.create(null), so they do not
|
||||
|
@ -85,7 +85,11 @@ export class SubchannelPool {
|
|||
/* Currently we do not delete keys with empty values. If that results
|
||||
* in significant memory usage we should change it. */
|
||||
|
||||
return allSubchannelsUnrefed;
|
||||
// Cancel the cleanup task if all subchannels have been unrefed.
|
||||
if (allSubchannelsUnrefed && this.cleanupTimer !== undefined) {
|
||||
clearInterval(this.cleanupTimer);
|
||||
this.cleanupTimer = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,19 +106,6 @@ export class SubchannelPool {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unrefs unused subchannels and cancels the cleanup task if all
|
||||
* subchannels have been unrefed.
|
||||
*/
|
||||
forceCleanup(): void {
|
||||
const allSubchannelsUnrefed = this.unrefUnusedSubchannels();
|
||||
|
||||
if (allSubchannelsUnrefed && this.cleanupTimer !== undefined) {
|
||||
clearInterval(this.cleanupTimer);
|
||||
this.cleanupTimer = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a subchannel if one already exists with exactly matching parameters.
|
||||
* Otherwise, create and save a subchannel with those parameters.
|
||||
|
|
Loading…
Reference in New Issue