mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
instantout/reservation: lock initial currentHeight write in Run
Run wrote m.currentHeight = height without holding the lock, while later writes (newBlockChan case) and reads in RequestReservationFromServer take m.Lock. Daemon startup serializes 'wait for initChan' before serving RPC, so in practice the race window is short, but the race detector flags it -- and on the nautilus side a similar pattern is the most plausible cause of the unit-race CI failure on the buy-reservations head commit. Symmetric fix here keeps the synchronisation rule uniform.
This commit is contained in:
parent
29c92a10ea
commit
10a50ef452
1 changed files with 6 additions and 0 deletions
|
|
@ -92,7 +92,13 @@ func (m *Manager) Run(ctx context.Context, height int32,
|
|||
runCtx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
// Take the lock for the initial write so the race detector sees a
|
||||
// consistent synchronisation rule (later writes in the new-block
|
||||
// case already lock; concurrent reads in RequestReservationFromServer
|
||||
// already lock).
|
||||
m.Lock()
|
||||
m.currentHeight = height
|
||||
m.Unlock()
|
||||
|
||||
err := m.RecoverReservations(runCtx)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue