summaryrefslogtreecommitdiffstats
path: root/git_command.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-05-06 00:44:42 -0400
committerMike Frysinger <vapier@google.com>2021-05-10 21:16:06 +0000
commit339f2df1ddd741070e340ec01d6882dd1eee617c (patch)
treed16fe7c87ba966a400d545bef5a49c460b75dc57 /git_command.py
parent19e409c81863878d5d313fdc40b3975b98602454 (diff)
downloadgit-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_command.py')
-rw-r--r--git_command.py12
1 files changed, 6 insertions, 6 deletions
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
21from git_refs import HEAD 21from git_refs import HEAD
22import platform_utils 22import platform_utils
23from repo_trace import REPO_TRACE, IsTrace, Trace 23from repo_trace import REPO_TRACE, IsTrace, Trace
24import ssh
25from wrapper import Wrapper 24from wrapper import Wrapper
26 25
27GIT = 'git' 26GIT = 'git'
@@ -167,7 +166,7 @@ class GitCommand(object):
167 capture_stderr=False, 166 capture_stderr=False,
168 merge_output=False, 167 merge_output=False,
169 disable_editor=False, 168 disable_editor=False,
170 ssh_proxy=False, 169 ssh_proxy=None,
171 cwd=None, 170 cwd=None,
172 gitdir=None): 171 gitdir=None):
173 env = self._GetBasicEnv() 172 env = self._GetBasicEnv()
@@ -175,8 +174,8 @@ class GitCommand(object):
175 if disable_editor: 174 if disable_editor:
176 env['GIT_EDITOR'] = ':' 175 env['GIT_EDITOR'] = ':'
177 if ssh_proxy: 176 if ssh_proxy:
178 env['REPO_SSH_SOCK'] = ssh.sock() 177 env['REPO_SSH_SOCK'] = ssh_proxy.sock()
179 env['GIT_SSH'] = ssh.proxy() 178 env['GIT_SSH'] = ssh_proxy.proxy
180 env['GIT_SSH_VARIANT'] = 'ssh' 179 env['GIT_SSH_VARIANT'] = 'ssh'
181 if 'http_proxy' in env and 'darwin' == sys.platform: 180 if 'http_proxy' in env and 'darwin' == sys.platform:
182 s = "'http.proxy=%s'" % (env['http_proxy'],) 181 s = "'http.proxy=%s'" % (env['http_proxy'],)
@@ -259,7 +258,7 @@ class GitCommand(object):
259 raise GitError('%s: %s' % (command[1], e)) 258 raise GitError('%s: %s' % (command[1], e))
260 259
261 if ssh_proxy: 260 if ssh_proxy:
262 ssh.add_client(p) 261 ssh_proxy.add_client(p)
263 262
264 self.process = p 263 self.process = p
265 if input: 264 if input:
@@ -271,7 +270,8 @@ class GitCommand(object):
271 try: 270 try:
272 self.stdout, self.stderr = p.communicate() 271 self.stdout, self.stderr = p.communicate()
273 finally: 272 finally:
274 ssh.remove_client(p) 273 if ssh_proxy:
274 ssh_proxy.remove_client(p)
275 self.rc = p.wait() 275 self.rc = p.wait()
276 276
277 @staticmethod 277 @staticmethod