Skip to content

Commit

Permalink
contractcourt/channel_arbitrator: add missing return on resolver exit
Browse files Browse the repository at this point in the history
This commit adds a missing return to the resolveContract method, that
will ensure the goroutine exits if the ChannelArbitrator shuts down.
This fixes a potential deadlock during the integration tests.

We also promote some of the logs to Debug from Trace.
  • Loading branch information
halseth committed Apr 13, 2018
1 parent 25d56ed commit c5169a7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions contractcourt/channel_arbitrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -1162,19 +1162,23 @@ func (c *ChannelArbitrator) resolveContract(currentContract ContractResolver) {
// Until the contract is fully resolved, we'll continue to iteratively
// resolve the contract one step at a time.
for !currentContract.IsResolved() {
log.Debugf("ChannelArbitrator(%v): contract %T not yet resolved",
c.cfg.ChanPoint, currentContract)

select {

// If we've been signalled to quit, then we'll exit early.
case <-c.quit:
return

default:
// Otherwise, we'll attempt to resolve the current
// contract.
nextContract, err := currentContract.Resolve()
if err != nil {
log.Errorf("ChannelArbitrator(%v): unable to "+
"progress resolver: %v", c.cfg.ChanPoint, err)
"progress resolver: %v",
c.cfg.ChanPoint, err)
return
}

Expand All @@ -1185,7 +1189,7 @@ func (c *ChannelArbitrator) resolveContract(currentContract ContractResolver) {
// within our logs: the new contract will take the
// place of the old one.
case nextContract != nil:
log.Tracef("ChannelArbitrator(%v): swapping "+
log.Debugf("ChannelArbitrator(%v): swapping "+
"out contract %T for %T ",
c.cfg.ChanPoint, currentContract,
nextContract)
Expand All @@ -1206,7 +1210,7 @@ func (c *ChannelArbitrator) resolveContract(currentContract ContractResolver) {
// If this contract is actually fully resolved, then
// we'll mark it as such within the database.
case currentContract.IsResolved():
log.Tracef("ChannelArbitrator(%v): marking "+
log.Debugf("ChannelArbitrator(%v): marking "+
"contract %T fully resolved",
c.cfg.ChanPoint, currentContract)

Expand Down

0 comments on commit c5169a7

Please sign in to comment.