Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a read deadline for the multistream select on dial #44

Merged
merged 1 commit into from Apr 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions p2p/net/conn/dial.go
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"math/rand"
"strings"
"time"

addrutil "github.com/ipfs/go-libp2p/p2p/net/swarm/addr"
transport "gx/ipfs/QmRHqYZs3Diy8YC3bW16zvs8VDDwS2ARKBuKwALxEMqibc/go-libp2p-transport"
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