Wrapping lock and unlock in an anonymous function so that we can use dfer on unlock such that it is called in the case of a panic.
This commit is contained in:
parent
c89ff2b19f
commit
def08d2710
1 changed files with 7 additions and 3 deletions
10
retry.go
10
retry.go
|
@ -125,9 +125,13 @@ func (r *realisClient) ThriftCallWithRetries(thriftCall auroraThriftCall) (*auro
|
|||
}
|
||||
|
||||
// Only allow one go-routine make use or modify the thrift client connection.
|
||||
r.lock.Lock()
|
||||
resp, clientErr = thriftCall()
|
||||
r.lock.Unlock()
|
||||
// Placing this in an anonymous function in order to create a new, short-lived stack allowing unlock
|
||||
// to be run in case of a panic inside of thriftCall.
|
||||
func() {
|
||||
r.lock.Lock()
|
||||
defer r.lock.Unlock()
|
||||
resp, clientErr = thriftCall()
|
||||
}()
|
||||
|
||||
// Check if our thrift call is returning an error. This is a retriable event as we don't know
|
||||
// if it was caused by network issues.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue