Skip to content

Commit 30f817c

Browse files
GODRIVER-2874 Directly reference conn existence (#1300)
1 parent d7091e0 commit 30f817c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

x/mongo/driver/topology/server.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,7 @@ func (s *Server) check() (description.Server, error) {
763763
if s.conn == nil || s.conn.closed() || s.checkWasCancelled() {
764764
// Create a new connection if this is the first check, the connection was closed after an error during the previous
765765
// check, or the previous check was cancelled.
766-
isNilConn := s.conn == nil
767-
if !isNilConn {
766+
if s.conn != nil {
768767
s.publishServerHeartbeatStartedEvent(s.conn.ID(), false)
769768
}
770769
// Create a new connection and add it's handshake RTT as a sample.
@@ -774,12 +773,12 @@ func (s *Server) check() (description.Server, error) {
774773
// Use the description from the connection handshake as the value for this check.
775774
s.rttMonitor.addSample(s.conn.helloRTT)
776775
descPtr = &s.conn.desc
777-
if !isNilConn {
776+
if s.conn != nil {
778777
s.publishServerHeartbeatSucceededEvent(s.conn.ID(), duration, s.conn.desc, false)
779778
}
780779
} else {
781780
err = unwrapConnectionError(err)
782-
if !isNilConn {
781+
if s.conn != nil {
783782
s.publishServerHeartbeatFailedEvent(s.conn.ID(), duration, err, false)
784783
}
785784
}

0 commit comments

Comments
 (0)