More robust port_server version checking
diff --git a/tools/run_tests/port_server.py b/tools/run_tests/port_server.py
index 48b6214..b953df9 100755
--- a/tools/run_tests/port_server.py
+++ b/tools/run_tests/port_server.py
@@ -38,6 +38,18 @@
 import sys
 import time
 
+
+# increment this number whenever making a change to ensure that
+# the changes are picked up by running CI servers
+# note that all changes must be backwards compatible
+_MY_VERSION = 2
+
+
+if len(sys.argv) == 2 and sys.argv[1] == 'dump_version':
+  print _MY_VERSION
+  sys.exit(0)
+
+
 argp = argparse.ArgumentParser(description='Server for httpcli_test')
 argp.add_argument('-p', '--port', default=12345, type=int)
 args = argp.parse_args()
@@ -47,9 +59,6 @@
 pool = []
 in_use = {}
 
-with open(__file__) as f:
-  _MY_VERSION = hashlib.sha1(f.read()).hexdigest()
-
 
 def refill_pool(max_timeout, req):
   """Scan for ports not marked for being in use"""
@@ -113,7 +122,7 @@
       del in_use[p]
       pool.append(p)
       self.log_message('drop port %d' % p)
-    elif self.path == '/version':
+    elif self.path == '/version_number':
       # fetch a version string and the current process pid
       self.send_response(200)
       self.send_header('Content-Type', 'text/plain')
@@ -128,7 +137,7 @@
       self.end_headers()
       now = time.time()
       self.wfile.write(yaml.dump({'pool': pool, 'in_use': dict((k, now - v) for k, v in in_use.iteritems())}))
-    elif self.path == '/quit':
+    elif self.path == '/quitquitquit':
       self.send_response(200)
       self.end_headers()
       keep_running = False
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index e938520..4e71e3e 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -713,21 +713,24 @@
   # if not running ==> start a new one
   # otherwise, leave it up
   try:
-    version = urllib2.urlopen('http://localhost:%d/version' % port_server_port,
-                              timeout=1).read()
-    print 'detected port server running'
+    version = int(urllib2.urlopen(
+        'http://localhost:%d/version_number' % port_server_port,
+        timeout=1).read())
+    print 'detected port server running version %d' % version
     running = True
-  except Exception:
+  except Exception as e:
     print 'failed to detect port server: %s' % sys.exc_info()[0]
+    print e.strerror
     running = False
   if running:
-    with open('tools/run_tests/port_server.py') as f:
-      current_version = hashlib.sha1(f.read()).hexdigest()
-      running = (version == current_version)
-      if not running:
-        print 'port_server version mismatch: killing the old one'
-        urllib2.urlopen('http://localhost:%d/quit' % port_server_port).read()
-        time.sleep(1)
+    current_version = int(subprocess.check_output(
+        [sys.executable, 'tools/run_tests/port_server.py', 'dump_version']))
+    print 'my port server is version %d' % current_version
+    running = (version >= current_version)
+    if not running:
+      print 'port_server version mismatch: killing the old one'
+      urllib2.urlopen('http://localhost:%d/quitquitquit' % port_server_port).read()
+      time.sleep(1)
   if not running:
     print 'starting port_server'
     port_log = open('portlog.txt', 'w')
@@ -773,7 +776,7 @@
   # start antagonists
   antagonists = [subprocess.Popen(['tools/run_tests/antagonist.py'])
                  for _ in range(0, args.antagonists)]
-  port_server_port = 9999
+  port_server_port = 32767
   _start_port_server(port_server_port)
   try:
     infinite_runs = runs_per_test == 0