File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
driver-core/src/main/com/mongodb/internal/connection Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,34 @@ public void run() {
227227 // to fire the ServerHeartbeatSucceededEvent
228228 continue ;
229229 }
230+ boolean isPollMode = serverSettings .getServerMonitoringMode ().equals (ServerMonitoringMode .POLL );
231+ ServerDescription unknownConnectingServerDescription = unknownConnectingServerDescription (serverId , null );
232+ ServerDescription currentServerDescription = unknownConnectingServerDescription ;
233+ try {
234+ while (!isClosed ) {
235+ ServerDescription previousServerDescription = currentServerDescription ;
236+ currentServerDescription = lookupServerDescription (currentServerDescription );
237+ boolean shouldStreamResponses = shouldStreamResponses (currentServerDescription );
238+ if (shouldStreamResponses ) {
239+ ensureRoundTripTimeMonitorStarted ();
240+ }
241+
242+ if (isClosed ) {
243+ continue ;
244+ }
245+
246+ if (currentCheckCancelled ) {
247+ waitForNext ();
248+ currentCheckCancelled = false ;
249+ continue ;
250+ }
251+
252+ // For POLL mode, if we just established initial connection, do an immediate heartbeat
253+ if (isPollMode && connection != null && !connection .isClosed ()
254+ && previousServerDescription .equals (unknownConnectingServerDescription )
255+ && currentServerDescription .equals (connection .getInitialServerDescription ())) {
256+ continue ;
257+ }
230258
231259 logStateChange (previousServerDescription , currentServerDescription );
232260 sdamProvider .get ().monitorUpdate (currentServerDescription );
You can’t perform that action at this time.
0 commit comments