Skip to content

Commit

Permalink
fully close streams when testing CanHop
Browse files Browse the repository at this point in the history
  • Loading branch information
Stebalien committed Jun 5, 2018
1 parent 6c449aa commit 98d6147
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions p2p/protocol/internal/circuitv1-deprecated/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,18 @@ func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error) {

msg.Type = pb.CircuitRelay_CAN_HOP.Enum()

err = wr.WriteMsg(&msg)
if err != nil {
if err := wr.WriteMsg(&msg); err != nil {
s.Reset()
return false, err
}

msg.Reset()

err = rd.ReadMsg(&msg)
s.Close()

if err != nil {
if err := rd.ReadMsg(&msg); err != nil {
s.Reset()
return false, err
}
if err := inet.FullClose(s); err != nil {
return false, err
}

Expand Down Expand Up @@ -369,7 +369,7 @@ func (r *Relay) handleCanHop(s inet.Stream, msg *pb.CircuitRelay) {
s.Reset()
log.Debugf("error writing relay response: %s", err.Error())
} else {
s.Close()
inet.FullClose(s)
}
}

Expand All @@ -380,7 +380,7 @@ func (r *Relay) handleError(s inet.Stream, code pb.CircuitRelay_Status) {
s.Reset()
log.Debugf("error writing relay response: %s", err.Error())
} else {
s.Close()
inet.FullClose(s)
}
}

Expand Down

0 comments on commit 98d6147

Please sign in to comment.