func (dl *dialLink) Link(reason error) (net.Conn, *bufio.Reader, SeqNo, error) {
	dl.x__.Lock()
	defer dl.x__.Unlock()

	if dl.carrier != nil {
		dl.carrier.Close()
	}
	if dl.carrier == nil && dl.ndial > 0 {
		return nil, nil, 0, io.ErrUnexpectedEOF
	}
	if dl.ndial > 0 {
		time.Sleep(CarrierRedialTimeout)
	}
	for {
		carrier, err := dl.dial()
		if err != nil {
			if err == ErrRIP {
				// Permanent error on the carrier connections dial attempts means
				// do not retry.
				dl.frame.Printf("permanently unreachable")
				return nil, nil, 0, err
			}
			// Non-permanent errors result in redial.
			dl.frame.Printf("redial because (%s)", err)
			time.Sleep(CarrierRedialTimeout + time.Duration((int64(CarrierRedialTimeout)*rand.Int63n(1e6))/1e6))
			continue
		}
		var broken bool
		if err, broken = dl.handshake(carrier); err != nil {
			if broken {
				log.Printf("dial rejected (%s)", err)
				return nil, nil, 0, ErrRIP
			}
			// All errors returned from dl.handshake where chainBroken is
			// false imply a broken carrier connection. We defer reporting the
			// broken connection error to the Conn object, which will spot it
			// when it tries to use the connection. This way, carrier-level
			// errors are treated uniformly within the Conn logic.
			// Furthermore, retrying from this error condition here would
			// break some test-only logic when the underlying sandbox
			// connection works in regime NOK=1 NDROP=0.
			log.Printf("carrier broke during handshake (%s)", err)
		}
		dl.carrier = carrier
		return dl.carrier, bufio.NewReader(carrier), dl.ndial, nil
	}
	panic("u")
}
// Link attempts to dial a new connection to the remote endpoint.
// If error is non-nil, the destination is permanently gone.
Link attempts to dial a new connection to the remote endpoint.
If error is non-nil, the destination is permanently gone.
// Link attempts to dial a new connection to the remote endpoint . // If error is non - nil the destination is permanently gone .
func (dl *dialLink) Link(reason error) (net.Conn, *bufio.Reader, SeqNo, error) {
	dl.x__.Lock()
	defer dl.x__.Unlock()
	if dl.carrier != nil {
		dl.carrier.Close()
	}
	if dl.carrier == nil && dl.ndial > 0 {
		return nil, nil, 0, io.ErrUnexpectedEOF
	}
	if dl.ndial > 0 {
		time.Sleep(CarrierRedialTimeout)
	}
	for {
		carrier, err := dl.dial()
		if err != nil {
			if err == ErrRIP {
				dl.frame.Printf("permanently unreachable")
				return nil, nil, 0, err
			}
			dl.frame.Printf("redial because (%s)", err)
			time.Sleep(CarrierRedialTimeout + time.Duration((int64(CarrierRedialTimeout)*rand.Int63n(1e6))/1e6))
			continue
		}
		var broken bool
		if err, broken = dl.handshake(carrier); err != nil {
			if broken {
				log.Printf("dial rejected (%s)", err)
				return nil, nil, 0, ErrRIP
			}
			log.Printf("carrier broke during handshake (%s)", err)
		}
		dl.carrier = carrier
		return dl.carrier, bufio.NewReader(carrier), dl.ndial, nil
	}
	panic("u")
}
func ( dl * dialLink ) Link ( reason error ) ( net . Conn , * bufio . Reader , SeqNo , error ) { dl . x__ . Lock ( ) defer dl . x__ . Unlock ( ) if dl . carrier != nil { dl . carrier . Close ( ) } if dl . carrier == nil && dl . ndial > 0 { return nil , nil , 0 , io . ErrUnexpectedEOF } if dl . ndial > 0 { time . Sleep ( CarrierRedialTimeout ) } for { carrier , err := dl . dial ( ) if err != nil { if err == ErrRIP { dl . frame . Printf ( " " ) return nil , nil , 0 , err } dl . frame . Printf ( " " , err ) time . Sleep ( CarrierRedialTimeout + time . Duration ( ( int64 ( CarrierRedialTimeout ) * rand . Int63n ( 1e6 ) ) / 1e6 ) ) continue } var broken bool if err , broken = dl . handshake ( carrier ) ; err != nil { if broken { log . Printf ( " " , err ) return nil , nil , 0 , ErrRIP } log . Printf ( " " , err ) } dl . carrier = carrier return dl . carrier , bufio . NewReader ( carrier ) , dl . ndial , nil } panic ( " " ) }
Link attempts to dial a new connection to the remote endpoint.
Link attempts to dial a new connection to the remote endpoint .
// Permanent error on the carrier connections dial attempts means // do not retry. // Non-permanent errors result in redial. // All errors returned from dl.handshake where chainBroken is // false imply a broken carrier connection. We defer reporting the // broken connection error to the Conn object, which will spot it // when it tries to use the connection. This way, carrier-level // errors are treated uniformly within the Conn logic. // Furthermore, retrying from this error condition here would // break some test-only logic when the underlying sandbox // connection works in regime NOK=1 NDROP=0.