Merge pull request #1079 from cfromknecht/chain-watcher-unlock

contractcourt/chain_watcher: release mutex on return
This commit is contained in:
Olaoluwa Osuntokun 2018-04-11 16:16:24 -07:00 committed by GitHub
commit f667e3b29f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -487,6 +487,7 @@ func (c *chainWatcher) dispatchCooperativeClose(commitSpend *chainntnfs.SpendDet
select { select {
case sub.CooperativeClosure <- struct{}{}: case sub.CooperativeClosure <- struct{}{}:
case <-c.quit: case <-c.quit:
c.Unlock()
return fmt.Errorf("exiting") return fmt.Errorf("exiting")
} }
} }
@ -536,6 +537,7 @@ func (c *chainWatcher) dispatchRemoteClose(commitSpend *chainntnfs.SpendDetail,
select { select {
case sub.UnilateralClosure <- uniClose: case sub.UnilateralClosure <- uniClose:
case <-c.quit: case <-c.quit:
c.Unlock()
return fmt.Errorf("exiting") return fmt.Errorf("exiting")
} }
} }
@ -600,6 +602,7 @@ func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail
select { select {
case sub.ContractBreach <- retribution: case sub.ContractBreach <- retribution:
case <-c.quit: case <-c.quit:
c.Unlock()
return fmt.Errorf("quitting") return fmt.Errorf("quitting")
} }
@ -611,11 +614,13 @@ func (c *chainWatcher) dispatchContractBreach(spendEvent *chainntnfs.SpendDetail
case err := <-sub.ProcessACK: case err := <-sub.ProcessACK:
// Bail if the handoff failed. // Bail if the handoff failed.
if err != nil { if err != nil {
c.Unlock()
return fmt.Errorf("unable to handoff "+ return fmt.Errorf("unable to handoff "+
"retribution info: %v", err) "retribution info: %v", err)
} }
case <-c.quit: case <-c.quit:
c.Unlock()
return fmt.Errorf("quitting") return fmt.Errorf("quitting")
} }
} }