From 339f2df1ddd741070e340ec01d6882dd1eee617c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 6 May 2021 00:44:42 -0400 Subject: ssh: rewrite proxy management for multiprocessing usage 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 Reviewed-by: Chris Mcdonald --- git_command.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'git_command.py') diff --git a/git_command.py b/git_command.py index fabad0e0..04953f38 100644 --- a/git_command.py +++ b/git_command.py @@ -21,7 +21,6 @@ from error import GitError from git_refs import HEAD import platform_utils from repo_trace import REPO_TRACE, IsTrace, Trace -import ssh from wrapper import Wrapper GIT = 'git' @@ -167,7 +166,7 @@ class GitCommand(object): capture_stderr=False, merge_output=False, disable_editor=False, - ssh_proxy=False, + ssh_proxy=None, cwd=None, gitdir=None): env = self._GetBasicEnv() @@ -175,8 +174,8 @@ class GitCommand(object): if disable_editor: env['GIT_EDITOR'] = ':' if ssh_proxy: - env['REPO_SSH_SOCK'] = ssh.sock() - env['GIT_SSH'] = ssh.proxy() + env['REPO_SSH_SOCK'] = ssh_proxy.sock() + env['GIT_SSH'] = ssh_proxy.proxy env['GIT_SSH_VARIANT'] = 'ssh' if 'http_proxy' in env and 'darwin' == sys.platform: s = "'http.proxy=%s'" % (env['http_proxy'],) @@ -259,7 +258,7 @@ class GitCommand(object): raise GitError('%s: %s' % (command[1], e)) if ssh_proxy: - ssh.add_client(p) + ssh_proxy.add_client(p) self.process = p if input: @@ -271,7 +270,8 @@ class GitCommand(object): try: self.stdout, self.stderr = p.communicate() finally: - ssh.remove_client(p) + if ssh_proxy: + ssh_proxy.remove_client(p) self.rc = p.wait() @staticmethod -- cgit v1.2.3-54-g00ecf