Merge pull request #173 from bhandras/hotfix

loopd: add missing mutex unlock and fix subtle reace condition
pull/174/head
Olaoluwa Osuntokun 4 years ago committed by GitHub
commit 605d3ac60b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -190,10 +190,10 @@ func (s *swapClientServer) Monitor(in *looprpc.MonitorRequest,
s.swapsLock.Unlock() s.swapsLock.Unlock()
defer func() { defer func() {
queue.Stop()
s.swapsLock.Lock() s.swapsLock.Lock()
delete(s.subscribers, id) delete(s.subscribers, id)
s.swapsLock.Unlock() s.swapsLock.Unlock()
queue.Stop()
}() }()
// Sort completed swaps new to old. // Sort completed swaps new to old.
@ -459,6 +459,7 @@ func (s *swapClientServer) processStatusUpdates(mainCtx context.Context) {
select { select {
case subscriber <- swp: case subscriber <- swp:
case <-mainCtx.Done(): case <-mainCtx.Done():
s.swapsLock.Unlock()
return return
} }
} }

Loading…
Cancel
Save