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