Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Don't abortConnection() if the transport connection has already closed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Half-Shot committed May 3, 2018
1 parent 7dcbcca commit 2e7a94c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions synapse/http/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,15 @@ def _time_things_out_maybe(self):
if time.time() - self.last_request >= 2.5 * 60:
self.abort()
# 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()
# since that will promptly close the underlying TCP connection.
self.transport.abortConnection()
# 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()

def request(self, request):
self.last_request = time.time()
Expand Down

0 comments on commit 2e7a94c

Please sign in to comment.