Skip to content

Commit

Permalink
Check if connection exists before allocating request ID
Browse files Browse the repository at this point in the history
Co-authored-by: Adrian Philipp <[email protected]>
  • Loading branch information
ruudk and adri committed Sep 23, 2020
1 parent 1a6b857 commit dfd8b71
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,19 @@ func (c *client) Do(req *Request) (resp *ResponsePipe, err error) {
}
}

// check if connection exists
if c.conn == nil {
err = fmt.Errorf("client connection has been closed")
return
}

// allocate request ID
reqID := c.ids.Alloc()

// create response pipe
resp = NewResponsePipe()
rwError, allDone := make(chan error), make(chan int)

// check if connection exists
if c.conn == nil {
err = fmt.Errorf("client connection has been closed")
return
}

// if there is a raw request, use the context deadline
var ctx context.Context
if req.Raw != nil {
Expand Down

0 comments on commit dfd8b71

Please sign in to comment.