diff --git a/proxy/core/connection/pool.py b/proxy/core/connection/pool.py index 16cd5096b1..67413cc781 100644 --- a/proxy/core/connection/pool.py +++ b/proxy/core/connection/pool.py @@ -7,10 +7,6 @@ :copyright: (c) 2013-present by Abhinav Singh and contributors. :license: BSD, see LICENSE for more details. - - .. spelling:: - - reusability """ import logging @@ -95,7 +91,7 @@ def release(self, conn: TcpServerConnection) -> None: """Release the connection. If the connection has not been closed, - then it will be retained in the pool for reusability. + then it will be retained in the pool for re-usability. """ if conn.closed: logger.debug( @@ -111,5 +107,5 @@ def release(self, conn: TcpServerConnection) -> None: ), ) assert not conn.is_reusable() - # Reset for reusability + # Reset for re-usability conn.reset() diff --git a/proxy/http/proxy/server.py b/proxy/http/proxy/server.py index 2fda84f8d5..9e9541a9ba 100644 --- a/proxy/http/proxy/server.py +++ b/proxy/http/proxy/server.py @@ -299,9 +299,10 @@ async def read_from_descriptors(self, r: Readables) -> bool: return self._close_and_release() if raw is None: - logger.debug('Server closed connection, tearing down...') - return self._close_and_release() - + if self.upstream.closed: + logger.debug('Server closed connection, tearing down...') + return self._close_and_release() + return False for plugin in self.plugins.values(): raw = plugin.handle_upstream_chunk(raw) @@ -794,7 +795,12 @@ def wrap_server(self) -> bool: assert isinstance(self.upstream.connection, socket.socket) do_close = False try: - self.upstream.wrap(text_(self.request.host), self.flags.ca_file) + # check if has wrapped already + logger.debug('type(self.upstream) = %s', type(self.upstream)) + if not isinstance(self.upstream.connection, ssl.SSLSocket): + self.upstream.wrap(text_(self.request.host), self.flags.ca_file) + else: + logger.debug('self.upstream is ssl.SSLSocket already, do not need to wrap') except ssl.SSLCertVerificationError: # Server raised certificate verification error # When --disable-interception-on-ssl-cert-verification-error flag is on, # we will cache such upstream hosts and avoid intercepting them for future