plugin XEP-0198: don't crash when xmlstream has been closed

This commit is contained in:
Goffi 2020-01-28 22:26:12 +01:00
commit 8252c15beb

View file

@ -1,8 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# SàT plugin for managing raw XML log
# Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
# SàT plugin for managing Stream-Management
# Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
@ -510,11 +509,16 @@ class XEP_0198(object):
def onAckTimeOut(self, client):
"""Called when a requested ACK has not been received in time"""
log.info(_("Ack was not received in time, aborting connection"))
transport = client.xmlstream.transport
if transport is None:
log.warning("transport was already removed")
try:
xmlstream = client.xmlstream
except AttributeError:
log.warning("xmlstream has already been terminated")
else:
transport.abortConnection()
transport = xmlstream.transport
if transport is None:
log.warning("transport was already removed")
else:
transport.abortConnection()
client._xep_0198_session.req_timer = None