Tweak federation sender wake-ups

This commit is contained in:
Neil Alexander 2020-07-07 15:54:06 +01:00
parent 9035e169b7
commit b152ee7c04
2 changed files with 13 additions and 2 deletions

View file

@ -225,7 +225,7 @@ func (oq *destinationQueue) backgroundSend() {
}
// If we have pending PDUs or EDUs then construct a transaction.
for oq.pendingPDUs.Load() > 0 || len(oq.pendingEDUs) > 0 {
if oq.pendingPDUs.Load() > 0 || len(oq.pendingEDUs) > 0 {
// Try sending the next transaction and see what happens.
transaction, terr := oq.nextTransaction(oq.pendingEDUs)
if terr != nil {
@ -275,6 +275,17 @@ func (oq *destinationQueue) backgroundSend() {
oq.cleanPendingInvites()
}
}
// If something else has come along since we sent the previous
// transactions then we want the next loop iteration to skip the
// wait and not go to sleep. In which case, if there isn't a
// wake-up message already, send one.
if oq.pendingPDUs.Load() > 0 {
select {
case oq.notifyPDUs <- true:
default:
}
}
}
}

View file

@ -93,7 +93,7 @@ func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *d
statistics: oqs.statistics.ForServer(destination),
incomingEDUs: make(chan *gomatrixserverlib.EDU, 128),
incomingInvites: make(chan *gomatrixserverlib.InviteV2Request, 128),
notifyPDUs: make(chan bool, 128),
notifyPDUs: make(chan bool, 1),
interruptBackoff: make(chan bool),
signing: oqs.signing,
}