mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-21 05:43:09 -06:00
Don't spin
This commit is contained in:
parent
9ad0781831
commit
0214ce3f4f
|
|
@ -164,6 +164,9 @@ func (oq *destinationQueue) wakeQueueIfNeeded() {
|
|||
} else {
|
||||
log.WithError(err).Errorf("Can't get pending PDU count for %q destination queue", oq.destination)
|
||||
}
|
||||
if count > 0 {
|
||||
oq.wakeServerCh <- true
|
||||
}
|
||||
// Then start the queue.
|
||||
go oq.backgroundSend()
|
||||
}
|
||||
|
|
@ -182,7 +185,6 @@ func (oq *destinationQueue) backgroundSend() {
|
|||
for {
|
||||
// If we have nothing to do then wait either for incoming events, or
|
||||
// until we hit an idle timeout.
|
||||
if oq.pendingPDUs.Load() == 0 && len(oq.pendingEDUs) == 0 && len(oq.pendingInvites) == 0 {
|
||||
select {
|
||||
case <-oq.wakeServerCh:
|
||||
// We were woken up because there are new PDUs waiting in the
|
||||
|
|
@ -222,7 +224,6 @@ func (oq *destinationQueue) backgroundSend() {
|
|||
// send.
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// If we are backing off this server then wait for the
|
||||
// backoff duration to complete first, or until explicitly
|
||||
|
|
@ -329,8 +330,10 @@ func (oq *destinationQueue) nextTransaction(
|
|||
// Ask the database for any pending PDUs from the next transaction.
|
||||
// maxPDUsPerTransaction is an upper limit but we probably won't
|
||||
// actually retrieve that many events.
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||
defer cancel()
|
||||
txid, pdus, err := oq.db.GetNextTransactionPDUs(
|
||||
context.TODO(), // context
|
||||
ctx, // context
|
||||
oq.destination, // server name
|
||||
maxPDUsPerTransaction, // max events to retrieve
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue