Merge pull request #173 from bhandras/hotfix

loopd: add missing mutex unlock and fix subtle reace condition
This commit is contained in:
Olaoluwa Osuntokun 2020-04-02 16:49:22 -07:00 committed by GitHub
commit 605d3ac60b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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