comparison sat/plugins/plugin_xep_0198.py @ 3133:87b8808ac49d

plugin XEP-0198: don't crash when xmlstream has been closed
author Goffi <goffi@goffi.org>
date Tue, 28 Jan 2020 22:26:12 +0100
parents ab2696e34d29
children ca61807f724c
comparison
equal deleted inserted replaced
3132:b64dd7c1496d 3133:87b8808ac49d
1 #!/usr/bin/env python3 1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*- 2
3 3 # SàT plugin for managing Stream-Management
4 # SàT plugin for managing raw XML log 4 # Copyright (C) 2009-2020 Jérôme Poisson (goffi@goffi.org)
5 # Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
6 5
7 # This program is free software: you can redistribute it and/or modify 6 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by 7 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or 8 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version. 9 # (at your option) any later version.
508 self.checkAcks(client) 507 self.checkAcks(client)
509 508
510 def onAckTimeOut(self, client): 509 def onAckTimeOut(self, client):
511 """Called when a requested ACK has not been received in time""" 510 """Called when a requested ACK has not been received in time"""
512 log.info(_("Ack was not received in time, aborting connection")) 511 log.info(_("Ack was not received in time, aborting connection"))
513 transport = client.xmlstream.transport 512 try:
514 if transport is None: 513 xmlstream = client.xmlstream
515 log.warning("transport was already removed") 514 except AttributeError:
516 else: 515 log.warning("xmlstream has already been terminated")
517 transport.abortConnection() 516 else:
517 transport = xmlstream.transport
518 if transport is None:
519 log.warning("transport was already removed")
520 else:
521 transport.abortConnection()
518 client._xep_0198_session.req_timer = None 522 client._xep_0198_session.req_timer = None
519 523
520 524
521 @implementer(iwokkel.IDisco) 525 @implementer(iwokkel.IDisco)
522 class XEP_0198_handler(xmlstream.XMPPHandler): 526 class XEP_0198_handler(xmlstream.XMPPHandler):