Using defer with unlock so that it may be called in case of a panic
This commit is contained in:
parent
6c14157357
commit
75ebda1860
1 changed files with 1 additions and 1 deletions
|
@ -427,6 +427,7 @@ type auroraThriftCall func() (resp *aurora.Response, err error)
|
|||
func (r *realisClient) thriftCallHelper(auroraCall auroraThriftCall) (*aurora.Response, error) {
|
||||
// Only allow one go-routine make use or modify the thrift client connection
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
resp, cliErr := auroraCall()
|
||||
|
||||
if cliErr != nil {
|
||||
|
@ -436,7 +437,6 @@ func (r *realisClient) thriftCallHelper(auroraCall auroraThriftCall) (*aurora.Re
|
|||
|
||||
return resp, retryConnErr
|
||||
}
|
||||
r.lock.Unlock()
|
||||
|
||||
if resp == nil {
|
||||
return nil, errors.New("Response is nil")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue