summaryrefslogtreecommitdiffstats
path: root/net/tools
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-20 09:11:42 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-20 09:11:42 +0000
commitf7458a0f0349d1496aea93d48fc6549a57cf8eec (patch)
tree3c614cfdd76916187cc38091172981f809b1ffbe /net/tools
parent3bc505f8bf627d85a09829020e0ed3265d060e52 (diff)
downloadchromium_src-f7458a0f0349d1496aea93d48fc6549a57cf8eec.zip
chromium_src-f7458a0f0349d1496aea93d48fc6549a57cf8eec.tar.gz
chromium_src-f7458a0f0349d1496aea93d48fc6549a57cf8eec.tar.bz2
Made testserver communicate to parent process with JSON
This is so that if the testserver needs to communicate anything more than the port in the future (e.g., xmpp port for the test sync server), it can do so in a flexible manner. BUG=53934 TEST=manually Review URL: http://codereview.chromium.org/5196001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@66879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/tools')
-rwxr-xr-xnet/tools/testserver/testserver.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py
index 2551139..b69eb2f 100755
--- a/net/tools/testserver/testserver.py
+++ b/net/tools/testserver/testserver.py
@@ -27,6 +27,13 @@ import time
import urlparse
import warnings
+# If we use simplejson always, we get some warnings when we run under
+# 2.6.
+if sys.version_info < (2, 6):
+ import simplejson as json
+else:
+ import json
+
# Ignore deprecation warnings, they make our output more cluttered.
warnings.filterwarnings("ignore", category=DeprecationWarning)
@@ -1321,15 +1328,22 @@ def main(options, args):
# Notify the parent that we've started. (BaseServer subclasses
# bind their sockets on construction.)
if options.startup_pipe is not None:
+ server_data = {
+ 'port': listen_port
+ }
+ server_data_json = json.dumps(server_data)
+ debug('sending server_data: %s' % server_data_json)
+ server_data_len = len(server_data_json)
if sys.platform == 'win32':
fd = msvcrt.open_osfhandle(options.startup_pipe, 0)
else:
fd = options.startup_pipe
startup_pipe = os.fdopen(fd, "w")
- # Write the listening port as a 2 byte value. This is _not_ using
- # network byte ordering since the other end of the pipe is on the same
- # machine.
- startup_pipe.write(struct.pack('@H', listen_port))
+ # First write the data length as an unsigned 4-byte value. This
+ # is _not_ using network byte ordering since the other end of the
+ # pipe is on the same machine.
+ startup_pipe.write(struct.pack('=L', server_data_len))
+ startup_pipe.write(server_data_json)
startup_pipe.close()
try: