]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
In the select()-based IOLoop, always listen for reads so we can tell
authorBen Darnell <ben@bendarnell.com>
Mon, 27 Sep 2010 21:08:56 +0000 (14:08 -0700)
committerBen Darnell <ben@bendarnell.com>
Mon, 27 Sep 2010 21:10:32 +0000 (14:10 -0700)
when the other side closed the connection.

Closes #37.

tornado/ioloop.py
tornado/test/web_test.py
tornado/web.py

index 02ab73c465bb8aa370d004bf5187037f863be585..ea34e0fe68e14b4fe67b6d6144ef57788f450117 100644 (file)
@@ -496,7 +496,12 @@ class _Select(object):
     def register(self, fd, events):
         if events & IOLoop.READ: self.read_fds.add(fd)
         if events & IOLoop.WRITE: self.write_fds.add(fd)
-        if events & IOLoop.ERROR: self.error_fds.add(fd)
+        if events & IOLoop.ERROR:
+            self.error_fds.add(fd)
+            # Closed connections are reported as errors by epoll and kqueue,
+            # but as zero-byte reads by select, so when errors are requested
+            # we need to listen for both read and error.
+            self.read_fds.add(fd)
 
     def modify(self, fd, events):
         self.unregister(fd)
index 181ffe5aca53c7f1bdd0eb58d879145c15dc6821..372fc68724e43b99d961d406e1b1c04655710041 100644 (file)
@@ -113,7 +113,3 @@ class ConnectionCloseTest(AsyncHTTPTestCase, LogTrapTestCase):
     def on_connection_close(self):
         logging.info('connection closed')
         self.stop()
-
-if tornado.ioloop._poll is tornado.ioloop._Select:
-    # select-based ioloop does not detect closed connections promptly
-    del ConnectionCloseTest
index b79399add96b5e2fbeeea59ca60fd823e829500c..a5bdb876cdba558f28f3460bfe4c69595cf5082a 100644 (file)
@@ -159,12 +159,6 @@ class RequestHandler(object):
         You may override this to clean up resources associated with
         long-lived connections.
 
-        Note that the select()-based implementation of IOLoop does not detect
-        closed connections and so this method will not be called until
-        you try (and fail) to produce some output.  The epoll- and kqueue-
-        based implementations should detect closed connections even while
-        the request is idle.
-
         Proxies may keep a connection open for a time (perhaps
         indefinitely) after the client has gone away, so this method
         may not be called promptly after the end user closes their