fix(events): unlock mutex before error returns

This commit is contained in:
Ian Davis 2020-12-09 13:37:56 +00:00
parent a999e41677
commit c6f5214657
No known key found for this signature in database
GPG Key ID: F3B290C645FE1783

View File

@ -153,6 +153,7 @@ func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence
best, err := e.tsc.best() best, err := e.tsc.best()
if err != nil { if err != nil {
e.lk.Unlock()
return xerrors.Errorf("error getting best tipset: %w", err) return xerrors.Errorf("error getting best tipset: %w", err)
} }
@ -177,6 +178,7 @@ func (e *heightEvents) ChainAt(hnd HeightHandler, rev RevertHandler, confidence
e.lk.Lock() e.lk.Lock()
best, err = e.tsc.best() best, err = e.tsc.best()
if err != nil { if err != nil {
e.lk.Unlock()
return xerrors.Errorf("error getting best tipset: %w", err) return xerrors.Errorf("error getting best tipset: %w", err)
} }
bestH = best.Height() bestH = best.Height()