func (cm *connectionMaker) connectionTerminated(conn Connection, err error) {
	cm.actionChan <- func() bool {
		if err != errConnectToSelf {
			cm.terminationCount++
		}
		delete(cm.connections, conn)
		if conn.isOutbound() {
			target := cm.targets[conn.remoteTCPAddress()]
			target.state = targetWaiting
			target.lastError = err
			_, peerNameCollision := err.(*peerNameCollisionError)
			switch {
			case peerNameCollision || err == errConnectToSelf:
				target.nextTryNever()
			case time.Now().After(target.tryAfter.Add(resetAfter)):
				target.nextTryNow()
			default:
				target.nextTryLater()
			}
		}
		return true
	}
}
func (cm *connectionMaker) connectionTerminated(conn Connection, err error) {
	cm.actionChan <- func() bool {
		if err != errConnectToSelf {
			cm.terminationCount++
		}
		delete(cm.connections, conn)
		if conn.isOutbound() {
			target := cm.targets[conn.remoteTCPAddress()]
			target.state = targetWaiting
			target.lastError = err
			_, peerNameCollision := err.(*peerNameCollisionError)
			switch {
			case peerNameCollision || err == errConnectToSelf:
				target.nextTryNever()
			case time.Now().After(target.tryAfter.Add(resetAfter)):
				target.nextTryNow()
			default:
				target.nextTryLater()
			}
		}
		return true
	}
}
func ( cm * connectionMaker ) connectionTerminated ( conn Connection , err error ) { cm . actionChan <- func ( ) bool { if err != errConnectToSelf { cm . terminationCount ++ } delete ( cm . connections , conn ) if conn . isOutbound ( ) { target := cm . targets [ conn . remoteTCPAddress ( ) ] target . state = targetWaiting target . lastError = err _ , peerNameCollision := err . ( * peerNameCollisionError ) switch { case peerNameCollision || err == errConnectToSelf : target . nextTryNever ( ) case time . Now ( ) . After ( target . tryAfter . Add ( resetAfter ) ) : target . nextTryNow ( ) default : target . nextTryLater ( ) } } return true } }
// connectionTerminated unregisters the passed connection, and marks the
// target identified by conn.RemoteTCPAddr() as Waiting.
connectionTerminated unregisters the passed connection and marks the target identified by conn . RemoteTCPAddr () as Waiting .