Skip to content

Commit

Permalink
if protocol selection fails, reset remembered protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Dec 17, 2016
1 parent 37377fd commit f32cc97
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion p2p/host/basic/basic_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package basichost

import (
"context"
"fmt"
"io"
"time"

Expand Down Expand Up @@ -219,7 +220,17 @@ func (h *BasicHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.I
}

if pref != "" {
return h.newStream(ctx, p, pref)
s, err := h.newStream(ctx, p, pref)
if err != msmux.ErrNotSupported {
return s, err
}

log.Warning("protocol preference selection failed: %s [%s] %s", p, pids, pref)

// protocol selection failed, clear ALL remembered protocols for them
if err := h.Peerstore().SetProtocols(p); err != nil {
return nil, fmt.Errorf("clearing peerstore protocols: %s", err)
}
}

var protoStrs []string
Expand Down

0 comments on commit f32cc97

Please sign in to comment.