Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(912)

Unified Diff: tools/valgrind/browser_wrapper_win.py

Issue 8816017: Fix rare logdir races by adding "_logdirfilecount" to the 'PID' when generating a unique logdir path (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/valgrind/browser_wrapper_win.py
===================================================================
--- tools/valgrind/browser_wrapper_win.py (revision 113180)
+++ tools/valgrind/browser_wrapper_win.py (working copy)
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import glob
import os
import re
import sys
@@ -11,7 +12,6 @@
# support layout_tests, remove Dr. Memory specific code and verify it works
# on a "clean" Mac.
-wrapper_pid = os.getpid()
testcase_name = None
for arg in sys.argv:
m = re.match("\-\-test\-name=(.*)", arg)
@@ -29,11 +29,20 @@
# http://code.google.com/p/drmemory/issues/detail?id=684 fixed.
logdir_idx = cmd_to_run.index("-logdir")
old_logdir = cmd_to_run[logdir_idx + 1]
-cmd_to_run[logdir_idx + 1] += "\\testcase.%d.logs" % wrapper_pid
+
+wrapper_pid = str(os.getpid())
+
+# On Windows, there is a chance of PID collision. We avoid it by appending the
+# number of entries in the logdir at the end of wrapper_pid.
+# This number is monotonic and we can't have two simultaneously running wrappers
+# with the same PID.
+wrapper_pid += "_%d" % len(glob.glob(old_logdir + "\\*"))
+
+cmd_to_run[logdir_idx + 1] += "\\testcase.%s.logs" % wrapper_pid
os.makedirs(cmd_to_run[logdir_idx + 1])
if testcase_name:
- f = open(old_logdir + "\\testcase.%d.name" % wrapper_pid, "w")
+ f = open(old_logdir + "\\testcase.%s.name" % wrapper_pid, "w")
print >>f, testcase_name
f.close()
« no previous file with comments | « no previous file | tools/valgrind/valgrind_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698