mirror of
https://github.com/element-hq/synapse
synced 2024-08-19 19:40:20 +00:00
Don't abortConnection() if the transport connection has already closed.
This commit is contained in:
parent
7dcbcca68c
commit
2e7a94c36b
1 changed files with 8 additions and 3 deletions
|
@ -113,10 +113,15 @@ class _WrappedConnection(object):
|
||||||
if time.time() - self.last_request >= 2.5 * 60:
|
if time.time() - self.last_request >= 2.5 * 60:
|
||||||
self.abort()
|
self.abort()
|
||||||
# Abort the underlying TLS connection. The abort() method calls
|
# Abort the underlying TLS connection. The abort() method calls
|
||||||
# loseConnection() on the underlying TLS connection which tries to
|
# loseConnection() on the TLS connection which tries to
|
||||||
# shutdown the connection cleanly. We call abortConnection()
|
# shutdown the connection cleanly. We call abortConnection()
|
||||||
# since that will promptly close the underlying TCP connection.
|
# since that will promptly close the TLS connection.
|
||||||
self.transport.abortConnection()
|
#
|
||||||
|
# In Twisted >18.4; the TLS connection will be None if it has closed
|
||||||
|
# which will make abortConnection() throw. Check that the TLS connection
|
||||||
|
# is not None before trying to close it.
|
||||||
|
if self.transport.getHandle() is not None:
|
||||||
|
self.transport.abortConnection()
|
||||||
|
|
||||||
def request(self, request):
|
def request(self, request):
|
||||||
self.last_request = time.time()
|
self.last_request = time.time()
|
||||||
|
|
Loading…
Reference in a new issue