core (xmpp): Cache unreachable server on presence error to avoid disco queries:
In case of dead server/component with lot of contacts, we may receive a lot of `<presence>` error with `remote-server-not-found` conditions. This patch use this to mark the server as unreachable and avoid to do disco queries there.
This commit is contained in:
parent
378f05ca35
commit
6e723b58a6
1 changed files with 19 additions and 0 deletions
|
|
@ -2268,6 +2268,25 @@ class SatPresenceProtocol(xmppim.PresenceClientProtocol):
|
|||
entity, C.PRESENCE_UNAVAILABLE, 0, statuses, self.parent.profile
|
||||
)
|
||||
|
||||
def errorReceived(self, presence):
|
||||
"""Handle error presence.
|
||||
|
||||
Cache unreachable servers to avoid future disco queries.
|
||||
"""
|
||||
try:
|
||||
e = error.exceptionFromStanza(presence)
|
||||
assert isinstance(e, error.StanzaError)
|
||||
if e.condition == "remote-server-not-found":
|
||||
from_jid = jid.JID(presence["from"])
|
||||
server_jid = jid.JID(from_jid.host)
|
||||
self.host.memory.disco._jid_disco_cache[server_jid] = (None, time.time())
|
||||
log.debug(
|
||||
f"Server {server_jid} marked as unreachable from "
|
||||
"presence error"
|
||||
)
|
||||
except Exception:
|
||||
log.exception("Can't handle presence error")
|
||||
|
||||
def available(self, entity=None, show=None, statuses=None, priority=None):
|
||||
"""Set a presence and statuses.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue