mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-20 21:33:19 -06:00
Don't stop when there is work to be done
This commit is contained in:
parent
a9aa3c263b
commit
4cc1eaac5a
|
|
@ -46,7 +46,6 @@ type destinationQueue struct {
|
||||||
running atomic.Bool // is the queue worker running?
|
running atomic.Bool // is the queue worker running?
|
||||||
backingOff atomic.Bool // true if we're backing off
|
backingOff atomic.Bool // true if we're backing off
|
||||||
statistics *types.ServerStatistics // statistics about this remote server
|
statistics *types.ServerStatistics // statistics about this remote server
|
||||||
incomingPDUs chan struct{} // signal that there are PDUs waiting
|
|
||||||
incomingInvites chan *gomatrixserverlib.InviteV2Request // invites to send
|
incomingInvites chan *gomatrixserverlib.InviteV2Request // invites to send
|
||||||
incomingEDUs chan *gomatrixserverlib.EDU // EDUs to send
|
incomingEDUs chan *gomatrixserverlib.EDU // EDUs to send
|
||||||
transactionID gomatrixserverlib.TransactionID // last transaction ID
|
transactionID gomatrixserverlib.TransactionID // last transaction ID
|
||||||
|
|
@ -54,6 +53,7 @@ type destinationQueue struct {
|
||||||
pendingPDUs atomic.Int32 // how many PDUs are waiting to be sent
|
pendingPDUs atomic.Int32 // how many PDUs are waiting to be sent
|
||||||
pendingEDUs []*gomatrixserverlib.EDU // owned by backgroundSend
|
pendingEDUs []*gomatrixserverlib.EDU // owned by backgroundSend
|
||||||
pendingInvites []*gomatrixserverlib.InviteV2Request // owned by backgroundSend
|
pendingInvites []*gomatrixserverlib.InviteV2Request // owned by backgroundSend
|
||||||
|
wakeServerCh chan bool // interrupts idle wait
|
||||||
retryServerCh chan bool // interrupts backoff
|
retryServerCh chan bool // interrupts backoff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,7 +120,7 @@ func (oq *destinationQueue) sendEvent(nid int64) {
|
||||||
// Signal that we've sent a new PDU. This will cause the queue to
|
// Signal that we've sent a new PDU. This will cause the queue to
|
||||||
// wake up if it's asleep.
|
// wake up if it's asleep.
|
||||||
oq.pendingPDUs.Add(1)
|
oq.pendingPDUs.Add(1)
|
||||||
oq.incomingPDUs <- struct{}{}
|
oq.wakeServerCh <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendEDU adds the EDU event to the pending queue for the destination.
|
// sendEDU adds the EDU event to the pending queue for the destination.
|
||||||
|
|
@ -168,10 +168,11 @@ func (oq *destinationQueue) backgroundSend() {
|
||||||
// e.g. in response to EDUs.
|
// e.g. in response to EDUs.
|
||||||
transactionID := gomatrixserverlib.TransactionID("")
|
transactionID := gomatrixserverlib.TransactionID("")
|
||||||
|
|
||||||
// Wait either for incoming events, or until we hit an
|
// If we have nothing to do then wait either for incoming events, or
|
||||||
// idle timeout.
|
// until we hit an idle timeout.
|
||||||
|
if oq.pendingPDUs.Load() == 0 {
|
||||||
select {
|
select {
|
||||||
case <-oq.incomingPDUs:
|
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
|
||||||
// database.
|
// database.
|
||||||
case edu := <-oq.incomingEDUs:
|
case edu := <-oq.incomingEDUs:
|
||||||
|
|
@ -209,6 +210,7 @@ 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
|
||||||
|
|
|
||||||
|
|
@ -88,9 +88,9 @@ func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *d
|
||||||
destination: destination,
|
destination: destination,
|
||||||
client: oqs.client,
|
client: oqs.client,
|
||||||
statistics: oqs.statistics.ForServer(destination),
|
statistics: oqs.statistics.ForServer(destination),
|
||||||
incomingPDUs: make(chan struct{}, 128),
|
|
||||||
incomingEDUs: make(chan *gomatrixserverlib.EDU, 128),
|
incomingEDUs: make(chan *gomatrixserverlib.EDU, 128),
|
||||||
incomingInvites: make(chan *gomatrixserverlib.InviteV2Request, 128),
|
incomingInvites: make(chan *gomatrixserverlib.InviteV2Request, 128),
|
||||||
|
wakeServerCh: make(chan bool, 128),
|
||||||
retryServerCh: make(chan bool),
|
retryServerCh: make(chan bool),
|
||||||
signing: oqs.signing,
|
signing: oqs.signing,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue