Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
fully close the autonat client stream
Browse files Browse the repository at this point in the history
The "correct" way to do this is to send an write, close, read, then read the
EOF. However, we don't really do that _anywhere_ in our code.
  • Loading branch information
Stebalien committed Apr 9, 2019
1 parent af9b2ab commit 86c0a65
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,24 @@ func (c *client) DialBack(ctx context.Context, p peer.ID) (ma.Multiaddr, error)
if err != nil {
return nil, err
}
defer s.Close()
// Might as well just reset the stream. Once we get to this point, we
// don't care about being nice.
defer inet.FullClose(s)

r := ggio.NewDelimitedReader(s, inet.MessageSizeMax)
w := ggio.NewDelimitedWriter(s)

req := newDialMessage(pstore.PeerInfo{ID: c.h.ID(), Addrs: c.getAddrs()})
err = w.WriteMsg(req)
if err != nil {
s.Reset()
return nil, err
}

var res pb.Message
err = r.ReadMsg(&res)
if err != nil {
s.Reset()
return nil, err
}

Expand Down

0 comments on commit 86c0a65

Please sign in to comment.