Skip to content

Commit

Permalink
Ignore errors when failing to set stream deadlines (#434)
Browse files Browse the repository at this point in the history
1. We set the deadline on the context as well, so the stream deadline
isn't actually critical.
2. The mock libp2p implementation doesn't support them.
  • Loading branch information
Stebalien authored Jul 9, 2024
1 parent 7782782 commit 502aa00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions certexchange/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ func (c *Client) Request(ctx context.Context, p peer.ID, req *Request) (_rh *Res
context.AfterFunc(ctx, func() { _ = stream.Reset() })

if deadline, ok := ctx.Deadline(); ok {
if err := stream.SetDeadline(deadline); err != nil {
return nil, nil, err
}
// Not all transports support deadlines.
_ = stream.SetDeadline(deadline)
}

br := &io.LimitedReader{R: bufio.NewReader(stream), N: 100}
Expand Down
5 changes: 2 additions & 3 deletions certexchange/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ func (s *Server) handleRequest(ctx context.Context, stream network.Stream) (_err
}()

if deadline, ok := ctx.Deadline(); ok {
if err := stream.SetDeadline(deadline); err != nil {
return err
}
// Not all transports support deadlines.
_ = stream.SetDeadline(deadline)
}

br := bufio.NewReader(stream)
Expand Down

0 comments on commit 502aa00

Please sign in to comment.