mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-18 04:13:10 -06:00
Review comments
This commit is contained in:
parent
b73139e68c
commit
743a3d783f
|
|
@ -94,8 +94,11 @@ func (oq *destinationQueue) sendInvite(ev *gomatrixserverlib.InviteV2Request) {
|
||||||
// backgroundSend is the worker goroutine for sending events.
|
// backgroundSend is the worker goroutine for sending events.
|
||||||
// nolint:gocyclo
|
// nolint:gocyclo
|
||||||
func (oq *destinationQueue) backgroundSend() {
|
func (oq *destinationQueue) backgroundSend() {
|
||||||
// Mark the worker as running for its lifetime.
|
// Check if a worker is already running, and if it isn't, then
|
||||||
oq.running.Store(true)
|
// mark it as started.
|
||||||
|
if !oq.running.CAS(false, true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
defer oq.running.Store(false)
|
defer oq.running.Store(false)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ func (oqs *OutgoingQueues) SendEvent(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove our own server from the list of destinations.
|
// Remove our own server from the list of destinations.
|
||||||
destinations = filterDestinations(oqs.origin, destinations)
|
destinations = filterAndDedupeDests(oqs.origin, destinations)
|
||||||
|
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
"destinations": destinations, "event": ev.EventID(),
|
"destinations": destinations, "event": ev.EventID(),
|
||||||
|
|
@ -145,7 +145,7 @@ func (oqs *OutgoingQueues) SendEDU(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove our own server from the list of destinations.
|
// Remove our own server from the list of destinations.
|
||||||
destinations = filterDestinations(oqs.origin, destinations)
|
destinations = filterAndDedupeDests(oqs.origin, destinations)
|
||||||
|
|
||||||
if len(destinations) > 0 {
|
if len(destinations) > 0 {
|
||||||
log.WithFields(log.Fields{
|
log.WithFields(log.Fields{
|
||||||
|
|
@ -160,9 +160,9 @@ func (oqs *OutgoingQueues) SendEDU(
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// filterDestinations removes our own server from the list of destinations.
|
// filterAndDedupeDests removes our own server from the list of destinations
|
||||||
// Otherwise we could end up trying to talk to ourselves.
|
// and deduplicates any servers in the list that may appear more than once.
|
||||||
func filterDestinations(origin gomatrixserverlib.ServerName, destinations []gomatrixserverlib.ServerName) (
|
func filterAndDedupeDests(origin gomatrixserverlib.ServerName, destinations []gomatrixserverlib.ServerName) (
|
||||||
result []gomatrixserverlib.ServerName,
|
result []gomatrixserverlib.ServerName,
|
||||||
) {
|
) {
|
||||||
strs := make([]string, len(destinations))
|
strs := make([]string, len(destinations))
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ package internal
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/Shopify/sarama"
|
"github.com/Shopify/sarama"
|
||||||
"github.com/matrix-org/dendrite/roomserver/api"
|
"github.com/matrix-org/dendrite/roomserver/api"
|
||||||
|
|
@ -68,7 +67,6 @@ func (r *RoomserverInternalAPI) InputRoomEvents(
|
||||||
// loopback room event containing the invite, for local invites.
|
// loopback room event containing the invite, for local invites.
|
||||||
// If it does, we should process it with the room events below.
|
// If it does, we should process it with the room events below.
|
||||||
if loopback != nil {
|
if loopback != nil {
|
||||||
fmt.Println("LOOPING BACK", string(loopback.Event.JSON()))
|
|
||||||
request.InputRoomEvents = append(request.InputRoomEvents, *loopback)
|
request.InputRoomEvents = append(request.InputRoomEvents, *loopback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue