Commit 7000bbe2 authored by bauerb@chromium.org's avatar bauerb@chromium.org

Handle broken pipe errors in Python testserver.


BUG=145734


Review URL: https://chromiumcodereview.appspot.com/11299307

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171049 0039d316-1c4b-4281-b951-d872f2087c98
parent c38f941e
......@@ -280,17 +280,9 @@ TEST_PPAPI_OUT_OF_PROCESS(BrowserFont)
TEST_PPAPI_IN_PROCESS(Buffer)
TEST_PPAPI_OUT_OF_PROCESS(Buffer)
// Python server crashes on Windows trybots and Linux Testers, which causes log
// parsing errors. http://crbug.com/145734
#if defined(OS_WIN) || defined(OS_LINUX)
#define MAYBE_TCPSocketPrivate DISABLED_TCPSocketPrivate
#else
#define MAYBE_TCPSocketPrivate TCPSocketPrivate
#endif
TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(MAYBE_TCPSocketPrivate)
TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(MAYBE_TCPSocketPrivate)
TEST_PPAPI_NACL_WITH_SSL_SERVER(MAYBE_TCPSocketPrivate)
TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate)
TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate)
TEST_PPAPI_NACL_WITH_SSL_SERVER(TCPSocketPrivate)
TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(TCPSocketPrivateTrusted)
TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(TCPSocketPrivateTrusted)
......
......@@ -113,6 +113,27 @@ class ClientRestrictingServerMixIn:
return client_address[0] == self.server_address[0]
class BrokenPipeHandlerMixIn:
"""Allows the server to deal with "broken pipe" errors (which happen if the
browser quits with outstanding requests, like for the favicon). This mix-in
requires the class to derive from SocketServer.BaseServer and not override its
handle_error() method. """
def handle_error(self, request, client_address):
value = sys.exc_info()[1]
if isinstance(value, socket.error):
err = value.args[0]
if sys.platform in ('win32', 'cygwin'):
# "An established connection was aborted by the software in your host."
pipe_err = 10053
else:
pipe_err = errno.EPIPE
if err == pipe_err:
print "testserver.py: Broken pipe"
return
SocketServer.BaseServer.handle_error(self, request, client_address)
class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
"""This is a specialization of BaseHTTPServer to allow it
to be exited cleanly (by setting its "stop" member to True)."""
......@@ -125,13 +146,17 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
self.socket.close()
class HTTPServer(ClientRestrictingServerMixIn, StoppableHTTPServer):
class HTTPServer(ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
StoppableHTTPServer):
"""This is a specialization of StoppableHTTPServer that adds client
verification."""
pass
class OCSPServer(ClientRestrictingServerMixIn, BaseHTTPServer.HTTPServer):
class OCSPServer(ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
BaseHTTPServer.HTTPServer):
"""This is a specialization of HTTPServer that serves an
OCSP response"""
......@@ -147,6 +172,7 @@ class OCSPServer(ClientRestrictingServerMixIn, BaseHTTPServer.HTTPServer):
class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
StoppableHTTPServer):
"""This is a specialization of StoppableHTTPServer that add https support and
client verification."""
......@@ -198,7 +224,9 @@ class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
return False
class SyncHTTPServer(ClientRestrictingServerMixIn, StoppableHTTPServer):
class SyncHTTPServer(ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
StoppableHTTPServer):
"""An HTTP server that handles sync commands."""
def __init__(self, server_address, xmpp_port, request_handler_class):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment