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) ...@@ -280,17 +280,9 @@ TEST_PPAPI_OUT_OF_PROCESS(BrowserFont)
TEST_PPAPI_IN_PROCESS(Buffer) TEST_PPAPI_IN_PROCESS(Buffer)
TEST_PPAPI_OUT_OF_PROCESS(Buffer) TEST_PPAPI_OUT_OF_PROCESS(Buffer)
// Python server crashes on Windows trybots and Linux Testers, which causes log TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate)
// parsing errors. http://crbug.com/145734 TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(TCPSocketPrivate)
#if defined(OS_WIN) || defined(OS_LINUX) TEST_PPAPI_NACL_WITH_SSL_SERVER(TCPSocketPrivate)
#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(TCPSocketPrivateTrusted) TEST_PPAPI_OUT_OF_PROCESS_WITH_SSL_SERVER(TCPSocketPrivateTrusted)
TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(TCPSocketPrivateTrusted) TEST_PPAPI_IN_PROCESS_WITH_SSL_SERVER(TCPSocketPrivateTrusted)
......
...@@ -113,6 +113,27 @@ class ClientRestrictingServerMixIn: ...@@ -113,6 +113,27 @@ class ClientRestrictingServerMixIn:
return client_address[0] == self.server_address[0] 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): class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
"""This is a specialization of BaseHTTPServer to allow it """This is a specialization of BaseHTTPServer to allow it
to be exited cleanly (by setting its "stop" member to True).""" to be exited cleanly (by setting its "stop" member to True)."""
...@@ -125,13 +146,17 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer): ...@@ -125,13 +146,17 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
self.socket.close() self.socket.close()
class HTTPServer(ClientRestrictingServerMixIn, StoppableHTTPServer): class HTTPServer(ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
StoppableHTTPServer):
"""This is a specialization of StoppableHTTPServer that adds client """This is a specialization of StoppableHTTPServer that adds client
verification.""" verification."""
pass pass
class OCSPServer(ClientRestrictingServerMixIn, BaseHTTPServer.HTTPServer): class OCSPServer(ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
BaseHTTPServer.HTTPServer):
"""This is a specialization of HTTPServer that serves an """This is a specialization of HTTPServer that serves an
OCSP response""" OCSP response"""
...@@ -147,6 +172,7 @@ class OCSPServer(ClientRestrictingServerMixIn, BaseHTTPServer.HTTPServer): ...@@ -147,6 +172,7 @@ class OCSPServer(ClientRestrictingServerMixIn, BaseHTTPServer.HTTPServer):
class HTTPSServer(tlslite.api.TLSSocketServerMixIn, class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
ClientRestrictingServerMixIn, ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
StoppableHTTPServer): StoppableHTTPServer):
"""This is a specialization of StoppableHTTPServer that add https support and """This is a specialization of StoppableHTTPServer that add https support and
client verification.""" client verification."""
...@@ -198,7 +224,9 @@ class HTTPSServer(tlslite.api.TLSSocketServerMixIn, ...@@ -198,7 +224,9 @@ class HTTPSServer(tlslite.api.TLSSocketServerMixIn,
return False return False
class SyncHTTPServer(ClientRestrictingServerMixIn, StoppableHTTPServer): class SyncHTTPServer(ClientRestrictingServerMixIn,
BrokenPipeHandlerMixIn,
StoppableHTTPServer):
"""An HTTP server that handles sync commands.""" """An HTTP server that handles sync commands."""
def __init__(self, server_address, xmpp_port, request_handler_class): 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