Fix a couple of bugs

This commit is contained in:
Neil Alexander 2020-12-07 12:58:36 +00:00
parent d4bd44ebe6
commit 147b3eddad
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -95,6 +95,8 @@ func (oq *destinationQueue) sendEvent(event *gomatrixserverlib.HeaderedEvent, re
pdu: event, pdu: event,
receipt: receipt, receipt: receipt,
}) })
} else {
oq.overflowed.Store(true)
} }
oq.pendingMutex.Unlock() oq.pendingMutex.Unlock()
// Wake up the queue if it's asleep. // Wake up the queue if it's asleep.
@ -136,6 +138,8 @@ func (oq *destinationQueue) sendEDU(event *gomatrixserverlib.EDU, receipt *share
edu: event, edu: event,
receipt: receipt, receipt: receipt,
}) })
} else {
oq.overflowed.Store(true)
} }
oq.pendingMutex.Unlock() oq.pendingMutex.Unlock()
// Wake up the queue if it's asleep. // Wake up the queue if it's asleep.
@ -302,10 +306,10 @@ func (oq *destinationQueue) backgroundSend() {
// the pending events and EDUs, and wipe our transaction ID. // the pending events and EDUs, and wipe our transaction ID.
oq.statistics.Success() oq.statistics.Success()
oq.pendingMutex.Lock() oq.pendingMutex.Lock()
for i := range oq.pendingPDUs { for i := range oq.pendingPDUs[:pc] {
oq.pendingPDUs[i] = nil oq.pendingPDUs[i] = nil
} }
for i := range oq.pendingEDUs { for i := range oq.pendingEDUs[:ec] {
oq.pendingEDUs[i] = nil oq.pendingEDUs[i] = nil
} }
oq.pendingPDUs = oq.pendingPDUs[pc:] oq.pendingPDUs = oq.pendingPDUs[pc:]