diff options
author | Mike Frysinger <vapier@google.com> | 2021-05-06 00:44:42 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-05-10 21:16:06 +0000 |
commit | 339f2df1ddd741070e340ec01d6882dd1eee617c (patch) | |
tree | d16fe7c87ba966a400d545bef5a49c460b75dc57 /git_config.py | |
parent | 19e409c81863878d5d313fdc40b3975b98602454 (diff) | |
download | git-repo-339f2df1ddd741070e340ec01d6882dd1eee617c.tar.gz |
ssh: rewrite proxy management for multiprocessing usagev2.15
We changed sync to use multiprocessing for parallel work. This broke
the ssh proxy code as it's all based on threads. Rewrite the logic to
be multiprocessing safe.
Now instead of the module acting as a stateful object, callers have to
instantiate a new ProxyManager class that holds all the state, an pass
that down to any users.
Bug: https://crbug.com/gerrit/12389
Change-Id: I4b1af116f7306b91e825d3c56fb4274c9b033562
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/305486
Tested-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Chris Mcdonald <cjmcdonald@google.com>
Diffstat (limited to 'git_config.py')
-rw-r--r-- | git_config.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/git_config.py b/git_config.py index d7fef8ca..978f6a59 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -27,7 +27,6 @@ import urllib.request | |||
27 | from error import GitError, UploadError | 27 | from error import GitError, UploadError |
28 | import platform_utils | 28 | import platform_utils |
29 | from repo_trace import Trace | 29 | from repo_trace import Trace |
30 | import ssh | ||
31 | from git_command import GitCommand | 30 | from git_command import GitCommand |
32 | from git_refs import R_CHANGES, R_HEADS, R_TAGS | 31 | from git_refs import R_CHANGES, R_HEADS, R_TAGS |
33 | 32 | ||
@@ -519,17 +518,23 @@ class Remote(object): | |||
519 | 518 | ||
520 | return self.url.replace(longest, longestUrl, 1) | 519 | return self.url.replace(longest, longestUrl, 1) |
521 | 520 | ||
522 | def PreConnectFetch(self): | 521 | def PreConnectFetch(self, ssh_proxy): |
523 | """Run any setup for this remote before we connect to it. | 522 | """Run any setup for this remote before we connect to it. |
524 | 523 | ||
525 | In practice, if the remote is using SSH, we'll attempt to create a new | 524 | In practice, if the remote is using SSH, we'll attempt to create a new |
526 | SSH master session to it for reuse across projects. | 525 | SSH master session to it for reuse across projects. |
527 | 526 | ||
527 | Args: | ||
528 | ssh_proxy: The SSH settings for managing master sessions. | ||
529 | |||
528 | Returns: | 530 | Returns: |
529 | Whether the preconnect phase for this remote was successful. | 531 | Whether the preconnect phase for this remote was successful. |
530 | """ | 532 | """ |
533 | if not ssh_proxy: | ||
534 | return True | ||
535 | |||
531 | connectionUrl = self._InsteadOf() | 536 | connectionUrl = self._InsteadOf() |
532 | return ssh.preconnect(connectionUrl) | 537 | return ssh_proxy.preconnect(connectionUrl) |
533 | 538 | ||
534 | def ReviewUrl(self, userEmail, validate_certs): | 539 | def ReviewUrl(self, userEmail, validate_certs): |
535 | if self._review_url is None: | 540 | if self._review_url is None: |