Skip to content

Commit

Permalink
Merge branch '1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
awh committed Nov 30, 2015
2 parents b2b6811 + 4420057 commit 0935e0a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions mesh/connection_maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (cm *ConnectionMaker) InitiateConnections(peers []string, replace bool) []e
for peer, addr := range addrs {
cm.directPeers[peer] = addr
// curtail any existing reconnect interval
if target, found := cm.targets[addr.String()]; found {
if target, found := cm.targets[cm.completeAddr(*addr)]; found {
target.nextTryNow()
}
}
Expand Down Expand Up @@ -159,6 +159,13 @@ func (cm *ConnectionMaker) queryLoop(actionChan <-chan ConnectionMakerAction) {
}
}

func (cm *ConnectionMaker) completeAddr(addr net.TCPAddr) string {
if addr.Port == 0 {
addr.Port = cm.port
}
return addr.String()
}

func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration {
var (
validTarget = make(map[string]struct{})
Expand All @@ -181,18 +188,16 @@ func (cm *ConnectionMaker) checkStateAndAttemptConnections() time.Duration {

// Add direct targets that are not connected
for _, addr := range cm.directPeers {
completeAddr := *addr
attempt := true
if completeAddr.Port == 0 {
completeAddr.Port = cm.port
if addr.Port == 0 {
// If a peer was specified w/o a port, then we do not
// attempt to connect to it if we have any inbound
// connections from that IP.
if _, connected := ourInboundIPs[completeAddr.IP.String()]; connected {
if _, connected := ourInboundIPs[addr.IP.String()]; connected {
attempt = false
}
}
address := completeAddr.String()
address := cm.completeAddr(*addr)
directTarget[address] = void
if attempt {
addTarget(address)
Expand Down

0 comments on commit 0935e0a

Please sign in to comment.