From 75ebda1860cdc44026832b8797461526cb0ffddf Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Fri, 19 Jan 2018 16:16:15 -0800 Subject: [PATCH] Using defer with unlock so that it may be called in case of a panic --- realis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/realis.go b/realis.go index 924d01d..bcca881 100644 --- a/realis.go +++ b/realis.go @@ -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")