mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Don't create queues for blacklisted hosts
This commit is contained in:
parent
89bf8c493e
commit
db78ec73e8
|
|
@ -159,10 +159,6 @@ func (oq *destinationQueue) sendEDU(event *gomatrixserverlib.EDU, receipt *share
|
||||||
// then we will interrupt the backoff, causing any federation
|
// then we will interrupt the backoff, causing any federation
|
||||||
// requests to retry.
|
// requests to retry.
|
||||||
func (oq *destinationQueue) wakeQueueIfNeeded() {
|
func (oq *destinationQueue) wakeQueueIfNeeded() {
|
||||||
// If the destination is blacklisted then do nothing.
|
|
||||||
if _, blacklisted := oq.statistics.BackoffInfo(); blacklisted {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// If we are backing off then interrupt the backoff.
|
// If we are backing off then interrupt the backoff.
|
||||||
if oq.backingOff.CAS(true, false) {
|
if oq.backingOff.CAS(true, false) {
|
||||||
oq.interruptBackoff <- true
|
oq.interruptBackoff <- true
|
||||||
|
|
|
||||||
|
|
@ -101,7 +101,6 @@ func NewOutgoingQueues(
|
||||||
signing: signing,
|
signing: signing,
|
||||||
queues: map[gomatrixserverlib.ServerName]*destinationQueue{},
|
queues: map[gomatrixserverlib.ServerName]*destinationQueue{},
|
||||||
}
|
}
|
||||||
queues.clearQueues()
|
|
||||||
// Look up which servers we have pending items for and then rehydrate those queues.
|
// Look up which servers we have pending items for and then rehydrate those queues.
|
||||||
if !disabled {
|
if !disabled {
|
||||||
time.AfterFunc(time.Second*5, func() {
|
time.AfterFunc(time.Second*5, func() {
|
||||||
|
|
@ -121,7 +120,7 @@ func NewOutgoingQueues(
|
||||||
log.WithError(err).Error("Failed to get EDU server names for destination queue hydration")
|
log.WithError(err).Error("Failed to get EDU server names for destination queue hydration")
|
||||||
}
|
}
|
||||||
for serverName := range serverNames {
|
for serverName := range serverNames {
|
||||||
if queue := queues.getQueue(serverName); !queue.statistics.Blacklisted() {
|
if queue := queues.getQueue(serverName); queue != nil {
|
||||||
queue.wakeQueueIfNeeded()
|
queue.wakeQueueIfNeeded()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,6 +148,9 @@ type queuedEDU struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *destinationQueue {
|
func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *destinationQueue {
|
||||||
|
if _, blacklisted := oqs.statistics.ForServer(destination).BackoffInfo(); blacklisted {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
oqs.queuesMutex.Lock()
|
oqs.queuesMutex.Lock()
|
||||||
defer oqs.queuesMutex.Unlock()
|
defer oqs.queuesMutex.Unlock()
|
||||||
oq := oqs.queues[destination]
|
oq := oqs.queues[destination]
|
||||||
|
|
@ -172,24 +174,10 @@ func (oqs *OutgoingQueues) getQueue(destination gomatrixserverlib.ServerName) *d
|
||||||
return oq
|
return oq
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oqs *OutgoingQueues) clearQueues() {
|
|
||||||
oqs.queuesMutex.Lock()
|
|
||||||
defer oqs.queuesMutex.Unlock()
|
|
||||||
for _, q := range oqs.queues {
|
|
||||||
oqs.clearQueue(q)
|
|
||||||
}
|
|
||||||
time.AfterFunc(time.Minute, oqs.clearQueues)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (oqs *OutgoingQueues) clearQueue(oq *destinationQueue) {
|
func (oqs *OutgoingQueues) clearQueue(oq *destinationQueue) {
|
||||||
oqs.queuesMutex.Lock()
|
oqs.queuesMutex.Lock()
|
||||||
defer oqs.queuesMutex.Unlock()
|
defer oqs.queuesMutex.Unlock()
|
||||||
switch {
|
|
||||||
case oq.running.Load():
|
|
||||||
return
|
|
||||||
case oq.backingOff.Load():
|
|
||||||
return
|
|
||||||
}
|
|
||||||
close(oq.notify)
|
close(oq.notify)
|
||||||
close(oq.interruptBackoff)
|
close(oq.interruptBackoff)
|
||||||
delete(oqs.queues, oq.destination)
|
delete(oqs.queues, oq.destination)
|
||||||
|
|
@ -262,7 +250,9 @@ func (oqs *OutgoingQueues) SendEvent(
|
||||||
}
|
}
|
||||||
|
|
||||||
for destination := range destmap {
|
for destination := range destmap {
|
||||||
oqs.getQueue(destination).sendEvent(ev, nid)
|
if queue := oqs.getQueue(destination); queue != nil {
|
||||||
|
queue.sendEvent(ev, nid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -332,7 +322,9 @@ func (oqs *OutgoingQueues) SendEDU(
|
||||||
}
|
}
|
||||||
|
|
||||||
for destination := range destmap {
|
for destination := range destmap {
|
||||||
oqs.getQueue(destination).sendEDU(e, nid)
|
if queue := oqs.getQueue(destination); queue != nil {
|
||||||
|
queue.sendEDU(e, nid)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -343,9 +335,7 @@ func (oqs *OutgoingQueues) RetryServer(srv gomatrixserverlib.ServerName) {
|
||||||
if oqs.disabled {
|
if oqs.disabled {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
q := oqs.getQueue(srv)
|
if queue := oqs.getQueue(srv); queue != nil {
|
||||||
if q == nil {
|
queue.wakeQueueIfNeeded()
|
||||||
return
|
|
||||||
}
|
}
|
||||||
q.wakeQueueIfNeeded()
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue