Skip to content

Commit

Permalink
chore: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfamador committed Feb 10, 2023
1 parent 95c4d5d commit 96084af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -1727,10 +1727,14 @@ func (c *Conn) localHostInfo(ctx context.Context) (*HostInfo, error) {
return nil, err
}

port := c.conn.RemoteAddr().(*net.TCPAddr).Port
addr := c.conn.RemoteAddr().(*net.TCPAddr)

// TODO(zariel): avoid doing this here
host, err := c.session.hostInfoFromMap(row, &HostInfo{connectAddress: c.host.connectAddress, port: port})
// If using a DNS address with a control connection enabled, it's possible that the connectAddress for
// the Conn struct does not actually match the IP address of the host that the Conn established
// a connection to since the HostDialer has dialed the DNS address again. Update the connectAddress
// to the remoteAddress of the connection to avoid mismatch IP's
host, err := c.session.hostInfoFromMap(row, &HostInfo{connectAddress: addr.IP, port: addr.Port})
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ func (s *Session) handleNodeUp(eventIp net.IP, eventPort int) {

host, ok := s.ring.getHostByIP(eventIp.String())
if !ok {
if err := s.hostSource.refreshRing(); err != nil && gocqlDebug {
s.logger.Printf("gocql: Session.handleNodeUp: failed to refresh ring: %w\n", err.Error())
}
return
}

Expand Down

0 comments on commit 96084af

Please sign in to comment.