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

Use of mux.ErrReset in mocknet #815

Merged
merged 1 commit into from
Mar 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions p2p/net/mock/mock_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync/atomic"
"time"

"github.com/libp2p/go-libp2p-core/mux"
"github.com/libp2p/go-libp2p-core/network"
protocol "github.com/libp2p/go-libp2p-core/protocol"
)
Expand All @@ -29,7 +30,6 @@ type stream struct {
stat network.Stat
}

var ErrReset error = errors.New("stream reset")
var ErrClosed error = errors.New("stream closed")

type transportObject struct {
Expand Down Expand Up @@ -98,8 +98,8 @@ func (s *stream) Close() error {

func (s *stream) Reset() error {
// Cancel any pending reads/writes with an error.
s.write.CloseWithError(ErrReset)
s.read.CloseWithError(ErrReset)
s.write.CloseWithError(mux.ErrReset)
s.read.CloseWithError(mux.ErrReset)

select {
case s.reset <- struct{}{}:
Expand Down Expand Up @@ -206,7 +206,7 @@ func (s *stream) transport() {
case s.reset <- struct{}{}:
default:
}
return ErrReset
return mux.ErrReset
}
if err := drainBuf(); err != nil {
return err
Expand All @@ -226,14 +226,14 @@ func (s *stream) transport() {
// Reset takes precedent.
select {
case <-s.reset:
s.writeErr = ErrReset
s.writeErr = mux.ErrReset
return
default:
}

select {
case <-s.reset:
s.writeErr = ErrReset
s.writeErr = mux.ErrReset
return
case <-s.close:
if err := drainBuf(); err != nil {
Expand Down