Commit 0436764f authored by Jeromy Johnson's avatar Jeromy Johnson
Browse files

Merge pull request #44 from ipfs/fix/dial-read-deadline

add a read deadline for the multistream select on dial
parents 17632a3b d8a6d25b
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"math/rand" "math/rand"
"strings" "strings"
"time"
ci "github.com/ipfs/go-libp2p-crypto" ci "github.com/ipfs/go-libp2p-crypto"
lgbl "github.com/ipfs/go-libp2p-loggables" lgbl "github.com/ipfs/go-libp2p-loggables"
...@@ -68,12 +69,16 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) ( ...@@ -68,12 +69,16 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
cryptoProtoChoice = NoEncryptionTag cryptoProtoChoice = NoEncryptionTag
} }
maconn.SetReadDeadline(time.Now().Add(NegotiateReadTimeout))
err = msmux.SelectProtoOrFail(cryptoProtoChoice, maconn) err = msmux.SelectProtoOrFail(cryptoProtoChoice, maconn)
if err != nil { if err != nil {
errOut = err errOut = err
return return
} }
maconn.SetReadDeadline(time.Time{})
c, err := newSingleConn(ctx, d.LocalPeer, remote, maconn) c, err := newSingleConn(ctx, d.LocalPeer, remote, maconn)
if err != nil { if err != nil {
maconn.Close() maconn.Close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment