clearQueue only called by defer so should be safe to delete queue in any case

This commit is contained in:
Neil Alexander 2021-02-17 13:43:41 +00:00
parent 6a5826cba4
commit d59b312df0
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
2 changed files with 7 additions and 8 deletions

View file

@ -247,7 +247,7 @@ func (oq *destinationQueue) backgroundSend() {
} }
destinationQueueRunning.Inc() destinationQueueRunning.Inc()
defer destinationQueueRunning.Dec() defer destinationQueueRunning.Dec()
defer oq.queues.clearQueue(oq.destination) defer oq.queues.clearQueue(oq)
defer oq.running.Store(false) defer oq.running.Store(false)
// Mark the queue as overflowed, so we will consult the database // Mark the queue as overflowed, so we will consult the database

View file

@ -171,15 +171,14 @@ func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *d
return oq return oq
} }
func (oqs *OutgoingQueues) clearQueue(destination gomatrixserverlib.ServerName) { func (oqs *OutgoingQueues) clearQueue(oq *destinationQueue) {
oqs.queuesMutex.Lock() oqs.queuesMutex.Lock()
defer oqs.queuesMutex.Unlock() defer oqs.queuesMutex.Unlock()
if oq, ok := oqs.queues[destination]; ok {
close(oq.notify) close(oq.notify)
close(oq.interruptBackoff) close(oq.interruptBackoff)
delete(oqs.queues, destination) delete(oqs.queues, oq.destination)
destinationQueueTotal.Dec() destinationQueueTotal.Dec()
}
} }
type ErrorFederationDisabled struct { type ErrorFederationDisabled struct {