mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
openchannel: fix shimPending data race
Protect the shimPending variable with a sync.Mutex since it is accessed from multiple goroutines: the main loop goroutine and the server error handling goroutine. Without synchronization this is a data race.
This commit is contained in:
parent
d2d8e71ea0
commit
eaf7883bcf
1 changed files with 8 additions and 0 deletions
|
|
@ -430,6 +430,7 @@ func (m *Manager) openChannelPsbt(ctx context.Context,
|
|||
|
||||
var (
|
||||
pendingChanID [32]byte
|
||||
shimMu sync.Mutex
|
||||
shimPending = true
|
||||
psbtFinalized bool
|
||||
basePsbtBytes []byte
|
||||
|
|
@ -466,6 +467,9 @@ func (m *Manager) openChannelPsbt(ctx context.Context,
|
|||
// maybeCancelShim is a helper function that cancels the funding shim
|
||||
// with the RPC server in case we end up aborting early.
|
||||
maybeCancelShim := func() {
|
||||
shimMu.Lock()
|
||||
defer shimMu.Unlock()
|
||||
|
||||
// If the user canceled while there was still a shim registered
|
||||
// with the wallet, release the resources now.
|
||||
if shimPending {
|
||||
|
|
@ -566,7 +570,9 @@ func (m *Manager) openChannelPsbt(ctx context.Context,
|
|||
err.Error(), cancelErr,
|
||||
) {
|
||||
|
||||
shimMu.Lock()
|
||||
shimPending = false
|
||||
shimMu.Unlock()
|
||||
}
|
||||
closeQuit()
|
||||
|
||||
|
|
@ -679,7 +685,9 @@ func (m *Manager) openChannelPsbt(ctx context.Context,
|
|||
// As soon as the channel is pending, there is no more
|
||||
// shim that needs to be canceled. If the user
|
||||
// interrupts now, we don't need to clean up anything.
|
||||
shimMu.Lock()
|
||||
shimPending = false
|
||||
shimMu.Unlock()
|
||||
|
||||
hash, err := chainhash.NewHash(
|
||||
update.ChanPending.Txid,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue