Skip to content

Commit

Permalink
Merge pull request #409 from charredlot/close-conn
Browse files Browse the repository at this point in the history
fix(query): always close client.conn in cancelQuery (issue #405)
  • Loading branch information
ernado authored Jul 1, 2024
2 parents 59b1bcc + b916fde commit f3dc1fe
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions query.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@ func (c *Client) cancelQuery() error {
Buf: make([]byte, 1),
}
proto.ClientCodeCancel.Encode(&b)

var retErr error
if err := c.flushBuf(ctx, &b); err != nil {
return errors.Wrap(err, "flush")
retErr = errors.Join(retErr, errors.Wrap(err, "flush"))
}

// Closing connection to prevent further queries.
// Always close connection to prevent further queries.
if err := c.Close(); err != nil {
return errors.Wrap(err, "close")
retErr = errors.Join(retErr, errors.Wrap(err, "close"))
}

return nil
return retErr
}

func (c *Client) querySettings(q Query) []proto.Setting {
Expand Down

0 comments on commit f3dc1fe

Please sign in to comment.