0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-12-15 09:23:50 +01:00

Merge pull request #3182 from Half-Shot/hs/fix-twisted-shutdown

Fix 'Unhandled Error' logs with Twisted 18.4
This commit is contained in:
Richard van der Hoff 2018-05-03 12:40:11 +01:00 committed by GitHub
commit 2117f84323
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,9 +115,14 @@ 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.
#
# 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() self.transport.abortConnection()
def request(self, request): def request(self, request):