Skip to content

Commit 605d3ac

Browse files
authored
Merge pull request #173 from bhandras/hotfix
loopd: add missing mutex unlock and fix subtle reace condition
2 parents bb38cf5 + f4be20c commit 605d3ac

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

loopd/swapclient_server.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest,
190190
s.swapsLock.Unlock()
191191

192192
defer func() {
193-
queue.Stop()
194193
s.swapsLock.Lock()
195194
delete(s.subscribers, id)
196195
s.swapsLock.Unlock()
196+
queue.Stop()
197197
}()
198198

199199
// Sort completed swaps new to old.
@@ -459,6 +459,7 @@ func (s *swapClientServer) processStatusUpdates(mainCtx context.Context) {
459459
select {
460460
case subscriber <- swp:
461461
case <-mainCtx.Done():
462+
s.swapsLock.Unlock()
462463
return
463464
}
464465
}

0 commit comments

Comments
 (0)