Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
a graceful shutdown of LND during the main chain backend sync check in certain
cases.

* [Fixed a bug](https://github.com/lightningnetwork/lnd/pull/9249) found in the
mission control store that can block the shutdown process of LND.

# New Features
## Functional Enhancements
## RPC Additions
Expand Down
15 changes: 13 additions & 2 deletions routing/missioncontrol_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ type missionControlStore struct {
wg sync.WaitGroup
db missionControlDB

// TODO(yy): Remove the usage of sync.Cond - we are better off using
// channes than a Cond as suggested in the official godoc.
//
// queueCond is signalled when items are put into the queue.
queueCond *sync.Cond

Expand Down Expand Up @@ -347,15 +350,23 @@ func (b *missionControlStore) run() {
// Wait for the queue to not be empty.
b.queueCond.L.Lock()
for b.queue.Front() == nil {
b.queueCond.Wait()

// To make sure we can properly stop, we must
// read the `done` channel first before
// attempting to call `Wait()`. This is due to
// the fact when `Signal` is called before the
// `Wait` call, the `Wait` call will block
// indefinitely.
//
// TODO(yy): replace this with channels.
select {
case <-b.done:
b.queueCond.L.Unlock()

return
default:
}

b.queueCond.Wait()
}
b.queueCond.L.Unlock()

Expand Down