Skip to content

Commit aae9997

Browse files
committed
refactor(sdam): track server connections in a different timer list
1 parent aa1a32c commit aae9997

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/core/sdam/topology.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ class Topology extends EventEmitter {
179179

180180
// timer management
181181
monitorTimers: [],
182-
iterationTimers: []
182+
iterationTimers: [],
183+
connectionTimers: []
183184
};
184185

185186
// amend options for server instance creation
@@ -339,6 +340,9 @@ class Topology extends EventEmitter {
339340
this.s.iterationTimers.map(timer => clearTimeout(timer));
340341
this.s.iterationTimers = [];
341342

343+
this.s.connectionTimers.map(timer => clearTimeout(timer));
344+
this.s.connectionTimers = [];
345+
342346
if (this.s.sessionPool) {
343347
this.s.sessions.forEach(session => session.endSession());
344348
this.s.sessionPool.endAllPooledSessions();
@@ -936,11 +940,11 @@ function createAndConnectServer(topology, serverDescription, connectDelay) {
936940

937941
if (connectDelay) {
938942
const connectTimer = setTimeout(() => {
939-
removeTimerFrom(connectTimer, topology.s.iterationTimers);
943+
removeTimerFrom(connectTimer, topology.s.connectionTimers);
940944
server.connect();
941945
}, connectDelay);
942946

943-
topology.s.iterationTimers.push(connectTimer);
947+
topology.s.connectionTimers.push(connectTimer);
944948
return server;
945949
}
946950

@@ -961,7 +965,7 @@ function resetServer(topology, serverDescription) {
961965
const newServer = createAndConnectServer(
962966
topology,
963967
serverDescription,
964-
topology.s.heartbeatFrequencyMS
968+
topology.s.minHeartbeatFrequencyMS
965969
);
966970

967971
topology.s.servers.set(serverDescription.address, newServer);

0 commit comments

Comments
 (0)