Skip to content

Commit

Permalink
GODRIVER-2874 Directly reference conn existence (#1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
prestonvasquez authored Jun 20, 2023
1 parent d7091e0 commit 30f817c
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions x/mongo/driver/topology/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,7 @@ func (s *Server) check() (description.Server, error) {
if s.conn == nil || s.conn.closed() || s.checkWasCancelled() {
// Create a new connection if this is the first check, the connection was closed after an error during the previous
// check, or the previous check was cancelled.
isNilConn := s.conn == nil
if !isNilConn {
if s.conn != nil {
s.publishServerHeartbeatStartedEvent(s.conn.ID(), false)
}
// Create a new connection and add it's handshake RTT as a sample.
Expand All @@ -774,12 +773,12 @@ func (s *Server) check() (description.Server, error) {
// Use the description from the connection handshake as the value for this check.
s.rttMonitor.addSample(s.conn.helloRTT)
descPtr = &s.conn.desc
if !isNilConn {
if s.conn != nil {
s.publishServerHeartbeatSucceededEvent(s.conn.ID(), duration, s.conn.desc, false)
}
} else {
err = unwrapConnectionError(err)
if !isNilConn {
if s.conn != nil {
s.publishServerHeartbeatFailedEvent(s.conn.ID(), duration, err, false)
}
}
Expand Down

0 comments on commit 30f817c

Please sign in to comment.