|
44 | 44 | from ...common.pki import gen_public_key, gen_csr, sign_csr |
45 | 45 |
|
46 | 46 | from ...core.event import eventNames |
47 | | -from ...core.connection import TcpServerConnection, ConnectionPool |
| 47 | +from ...core.connection import TcpServerConnection |
48 | 48 | from ...core.connection import TcpConnectionUninitializedException |
49 | 49 | from ...common.flag import flags |
50 | 50 |
|
@@ -140,9 +140,6 @@ class HttpProxyPlugin(HttpProtocolHandlerPlugin): |
140 | 140 | # connection pool operations. |
141 | 141 | lock = threading.Lock() |
142 | 142 |
|
143 | | - # Shared connection pool |
144 | | - pool = ConnectionPool() |
145 | | - |
146 | 143 | def __init__( |
147 | 144 | self, |
148 | 145 | *args: Any, **kwargs: Any, |
@@ -200,10 +197,10 @@ def get_descriptors(self) -> Tuple[List[int], List[int]]: |
200 | 197 |
|
201 | 198 | def _close_and_release(self) -> bool: |
202 | 199 | if self.flags.enable_conn_pool: |
203 | | - assert self.upstream and not self.upstream.closed |
| 200 | + assert self.upstream and not self.upstream.closed and self.upstream_conn_pool |
204 | 201 | self.upstream.closed = True |
205 | 202 | with self.lock: |
206 | | - self.pool.release(self.upstream) |
| 203 | + self.upstream_conn_pool.release(self.upstream) |
207 | 204 | self.upstream = None |
208 | 205 | return True |
209 | 206 |
|
@@ -391,9 +388,10 @@ def on_client_connection_close(self) -> None: |
391 | 388 | return |
392 | 389 |
|
393 | 390 | if self.flags.enable_conn_pool: |
| 391 | + assert self.upstream_conn_pool |
394 | 392 | # Release the connection for reusability |
395 | 393 | with self.lock: |
396 | | - self.pool.release(self.upstream) |
| 394 | + self.upstream_conn_pool.release(self.upstream) |
397 | 395 | return |
398 | 396 |
|
399 | 397 | try: |
@@ -589,8 +587,9 @@ def connect_upstream(self) -> None: |
589 | 587 | host, port = self.request.host, self.request.port |
590 | 588 | if host and port: |
591 | 589 | if self.flags.enable_conn_pool: |
| 590 | + assert self.upstream_conn_pool |
592 | 591 | with self.lock: |
593 | | - created, self.upstream = self.pool.acquire( |
| 592 | + created, self.upstream = self.upstream_conn_pool.acquire( |
594 | 593 | text_(host), port, |
595 | 594 | ) |
596 | 595 | else: |
@@ -642,8 +641,9 @@ def connect_upstream(self) -> None: |
642 | 641 | ), |
643 | 642 | ) |
644 | 643 | if self.flags.enable_conn_pool: |
| 644 | + assert self.upstream_conn_pool |
645 | 645 | with self.lock: |
646 | | - self.pool.release(self.upstream) |
| 646 | + self.upstream_conn_pool.release(self.upstream) |
647 | 647 | raise ProxyConnectionFailed( |
648 | 648 | text_(host), port, repr(e), |
649 | 649 | ) from e |
|
0 commit comments