Skip to content

Commit

Permalink
sweep: remove redundant notifications during shutdown
Browse files Browse the repository at this point in the history
This commit removes the hack introduced in lightningnetwork#4851. Previously we had this
issue because the chain notifier was stopped before the sweeper, which
was changed a while back and we now always stop the chain notifier last.
In addition, since we no longer subscribe to the block epoch chan
directly, this issue can no longer happen.
  • Loading branch information
yyforyongyu committed Dec 20, 2024
1 parent d970cf5 commit 8a7c8eb
Showing 1 changed file with 1 addition and 32 deletions.
33 changes: 1 addition & 32 deletions sweep/sweeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,38 +454,7 @@ func (s *UtxoSweeper) Start() error {

// Start sweeper main loop.
s.wg.Add(1)
go func() {
defer s.wg.Done()

s.collector()

// The collector exited and won't longer handle incoming
// requests. This can happen on shutdown, when the block
// notifier shuts down before the sweeper and its clients. In
// order to not deadlock the clients waiting for their requests
// being handled, we handle them here and immediately return an
// error. When the sweeper finally is shut down we can exit as
// the clients will be notified.
for {
select {
case inp := <-s.newInputs:
inp.resultChan <- Result{
Err: ErrSweeperShuttingDown,
}

case req := <-s.pendingSweepsReqs:
req.errChan <- ErrSweeperShuttingDown

case req := <-s.updateReqs:
req.responseChan <- &updateResp{
err: ErrSweeperShuttingDown,
}

case <-s.quit:
return
}
}
}()
go s.collector()

return nil
}
Expand Down

0 comments on commit 8a7c8eb

Please sign in to comment.