Skip to content

Commit

Permalink
Merge pull request #44 from ipfs/fix/dial-read-deadline
Browse files Browse the repository at this point in the history
add a read deadline for the multistream select on dial
  • Loading branch information
whyrusleeping committed Apr 27, 2016
2 parents 17632a3 + d8a6d25 commit 0436764
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions p2p/net/conn/dial.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/rand"
"strings"
"time"

ci "github.com/ipfs/go-libp2p-crypto"
lgbl "github.com/ipfs/go-libp2p-loggables"
Expand Down Expand Up @@ -68,12 +69,16 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
cryptoProtoChoice = NoEncryptionTag
}

maconn.SetReadDeadline(time.Now().Add(NegotiateReadTimeout))

err = msmux.SelectProtoOrFail(cryptoProtoChoice, maconn)
if err != nil {
errOut = err
return
}

maconn.SetReadDeadline(time.Time{})

c, err := newSingleConn(ctx, d.LocalPeer, remote, maconn)
if err != nil {
maconn.Close()
Expand Down

0 comments on commit 0436764

Please sign in to comment.