Skip to content

Commit

Permalink
client:fix ttrpc send hang
Browse files Browse the repository at this point in the history
Signed-off-by: ningmingxiao <[email protected]>
  • Loading branch information
ningmingxiao committed Sep 11, 2024
1 parent 3f02183 commit 155767a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,14 @@ func (c *Client) dispatch(ctx context.Context, req *Request, resp *Response) err
return err
}

s, err := c.createStream(0, p)
if err != nil {
return err
}
var s *stream
ch := make(chan error)
go func() {
s, err = c.createStream(0, p)
if err != nil {
ch <- err
}
}()
defer c.deleteStream(s)

var msg *streamMessage
Expand All @@ -547,6 +551,8 @@ func (c *Client) dispatch(ctx context.Context, req *Request, resp *Response) err
return ctx.Err()
case <-c.ctx.Done():
return ErrClosed
case err := <-ch:
return err
case <-s.recvClose:
// If recv has a pending message, process that first
select {
Expand Down

0 comments on commit 155767a

Please sign in to comment.