diff --git a/federationsender/queue/destinationqueue.go b/federationsender/queue/destinationqueue.go index f1f994034..be63290c6 100644 --- a/federationsender/queue/destinationqueue.go +++ b/federationsender/queue/destinationqueue.go @@ -247,7 +247,7 @@ func (oq *destinationQueue) backgroundSend() { } destinationQueueRunning.Inc() defer destinationQueueRunning.Dec() - defer oq.queues.clearQueue(oq.destination) + defer oq.queues.clearQueue(oq) defer oq.running.Store(false) // Mark the queue as overflowed, so we will consult the database diff --git a/federationsender/queue/queue.go b/federationsender/queue/queue.go index f77347445..56c81e64b 100644 --- a/federationsender/queue/queue.go +++ b/federationsender/queue/queue.go @@ -171,15 +171,14 @@ func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *d return oq } -func (oqs *OutgoingQueues) clearQueue(destination gomatrixserverlib.ServerName) { +func (oqs *OutgoingQueues) clearQueue(oq *destinationQueue) { oqs.queuesMutex.Lock() defer oqs.queuesMutex.Unlock() - if oq, ok := oqs.queues[destination]; ok { - close(oq.notify) - close(oq.interruptBackoff) - delete(oqs.queues, destination) - destinationQueueTotal.Dec() - } + + close(oq.notify) + close(oq.interruptBackoff) + delete(oqs.queues, oq.destination) + destinationQueueTotal.Dec() } type ErrorFederationDisabled struct {