Use an md5 hash of the tmpdir for the autoninja reclient pipe on windows

This is required because colons trigger an reproxy bug with named pipes
currently and backslashes are technically invalid for named pipes
https://learn.microsoft.com/en-us/windows/win32/ipc/pipe-names

I considered replacing invalid characters with underscores but that may
just push the problem down the road as it may create overlap between a
directory with underscores and a directory with an invalid charachter
that we replace.

Since windows doesn't treat pipes as files, like linux treats sockets
this naming is arbitrary, it only needs to be consistent and unique
for a given output directory. So md5 is a good solution.

Bug: b/271310759
Change-Id: I45409d7e9dc4cc1d0f056a3de8241ac877e682e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4300857
Commit-Queue: Ben Segall <bentekkie@google.com>
Auto-Submit: Ben Segall <bentekkie@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
changes/57/4300857/9
Ben Segall 2 years ago committed by LUCI CQ
parent f792c24879
commit 87fa610fe0

@ -7,6 +7,7 @@ handles the client lifecycle safely. It will automatically start
reproxy before running ninja and stop reproxy when ninja stops
for any reason eg. build completes, keyboard interupt etc."""
import hashlib
import os
import subprocess
import sys
@ -88,7 +89,7 @@ def set_reproxy_path_flags(out_dir):
*Nix Only:
RBE_server_address=unix://out_dir/.reproxy_tmp/reproxy.sock
Windows Only:
RBE_server_address=pipe://out_dir/.reproxy_tmp/reproxy.pipe
RBE_server_address=pipe://md5(out_dir/.reproxy_tmp)/reproxy.pipe
"""
tmp_dir = os.path.abspath(os.path.join(out_dir, '.reproxy_tmp'))
os.makedirs(tmp_dir, exist_ok=True)
@ -101,8 +102,9 @@ def set_reproxy_path_flags(out_dir):
os.makedirs(cache_dir, exist_ok=True)
os.environ.setdefault("RBE_cache_dir", cache_dir)
if sys.platform.startswith('win'):
pipe_dir = hashlib.md5(tmp_dir.encode()).hexdigest()
os.environ.setdefault("RBE_server_address",
"pipe://%s/reproxy.pipe" % tmp_dir)
"pipe://%s/reproxy.pipe" % pipe_dir)
else:
os.environ.setdefault("RBE_server_address",
"unix://%s/reproxy.sock" % tmp_dir)

@ -3,6 +3,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import hashlib
import os
import os.path
import sys
@ -70,8 +71,10 @@ class NinjaReclientTest(trial_dir.TestCase):
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp", "cache"))
if sys.platform.startswith('win'):
self.assertEqual(
os.environ.get('RBE_server_address'), "pipe://%s/reproxy.pipe" %
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp"))
os.environ.get('RBE_server_address'),
"pipe://%s/reproxy.pipe" % hashlib.md5(
os.path.join(self.root_dir, "out", "a",
".reproxy_tmp").encode()).hexdigest())
else:
self.assertEqual(
os.environ.get('RBE_server_address'), "unix://%s/reproxy.sock" %

Loading…
Cancel
Save