diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-20 21:23:44 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-20 21:23:44 +0000 |
commit | 865394df590aabeeb15db51ac159f165fd6d9c9c (patch) | |
tree | 920a46f5bdc3bba6ae267ac4e16944f4923978a1 /net | |
parent | 0ea3726128e3865dafd320acd4cf335a1fcba43d (diff) | |
download | chromium_src-865394df590aabeeb15db51ac159f165fd6d9c9c.zip chromium_src-865394df590aabeeb15db51ac159f165fd6d9c9c.tar.gz chromium_src-865394df590aabeeb15db51ac159f165fd6d9c9c.tar.bz2 |
[Sync] Fixed bug in test sync server's select loop.
This fixes one problem causing flakiness on the linux sync integration test
trybot.
BUG=67051
TEST=sync_integration_tests
Review URL: http://codereview.chromium.org/5968001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rwxr-xr-x | net/tools/testserver/testserver.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/net/tools/testserver/testserver.py b/net/tools/testserver/testserver.py index 0cd663d..56d7c0e 100755 --- a/net/tools/testserver/testserver.py +++ b/net/tools/testserver/testserver.py @@ -151,17 +151,22 @@ class SyncHTTPServer(StoppableHTTPServer): """This is a merge of asyncore.loop() and SocketServer.serve_forever(). """ - def RunDispatcherHandler(dispatcher, handler): - """Handles a single event for an asyncore.dispatcher. + def HandleXmppSocket(fd, socket_map, handler): + """Runs the handler for the xmpp connection for fd. Adapted from asyncore.read() et al. """ + xmpp_connection = socket_map.get(fd) + # This could happen if a previous handler call caused fd to get + # removed from socket_map. + if xmpp_connection is None: + return try: - handler(dispatcher) + handler(xmpp_connection) except (asyncore.ExitNow, KeyboardInterrupt, SystemExit): raise except: - dispatcher.handle_error() + xmpp_connection.handle_error() while True: read_fds = [ self.fileno() ] @@ -191,19 +196,16 @@ class SyncHTTPServer(StoppableHTTPServer): if fd == self.fileno(): self.HandleRequestNoBlock() continue - xmpp_connection = self._xmpp_socket_map.get(fd) - RunDispatcherHandler(xmpp_connection, - asyncore.dispatcher.handle_read_event) + HandleXmppSocket(fd, self._xmpp_socket_map, + asyncore.dispatcher.handle_read_event) for fd in write_fds: - xmpp_connection = self._xmpp_socket_map.get(fd) - RunDispatcherHandler(xmpp_connection, - asyncore.dispatcher.handle_write_event) + HandleXmppSocket(fd, self._xmpp_socket_map, + asyncore.dispatcher.handle_write_event) for fd in exceptional_fds: - xmpp_connection = self._xmpp_socket_map.get(fd) - RunDispatcherHandler(xmpp_connection, - asyncore.dispatcher.handle_expt_event) + HandleXmppSocket(fd, self._xmpp_socket_map, + asyncore.dispatcher.handle_expt_event) class BasePageHandler(BaseHTTPServer.BaseHTTPRequestHandler): |