]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Use a AND instead of an OR to determine if the bits are set on the event 389/head
authorDavid Koblas <koblas@extra.com>
Tue, 25 Oct 2011 22:24:41 +0000 (15:24 -0700)
committerDavid Koblas <koblas@extra.com>
Tue, 25 Oct 2011 22:24:41 +0000 (15:24 -0700)
mask.  Also, handle some basic error cases in the event bits and twisted
callback.

tornado/platform/twisted.py

index 04a32de7167b592ebe7f2450e63ce0e508873b4f..25fe36f3513b8082d4f22c261368f7ccc9c2f8fb 100644 (file)
@@ -32,6 +32,8 @@ import time
 from twisted.internet.posixbase import PosixReactorBase
 from twisted.internet.interfaces import \
     IReactorFDSet, IDelayedCall, IReactorTime
+from twisted.python import failure
+from twisted.internet import error
 
 from zope.interface import implements
 
@@ -40,6 +42,7 @@ import tornado.ioloop
 from tornado.stack_context import NullContext
 from tornado.ioloop import IOLoop
 
+
 class TornadoDelayedCall(object):
     """
     DelayedCall object for Tornado.
@@ -139,10 +142,15 @@ class TornadoReactor(PosixReactorBase):
     # IReactorFDSet
     def _invoke_callback(self, fd, events):
         (reader, writer) = self._fds[fd]
-        if events | IOLoop.READ and reader:
+        if events & IOLoop.READ and reader:
             reader.doRead()
-        if events | IOLoop.WRITE and writer:
+        if events & IOLoop.WRITE and writer:
             writer.doWrite()
+       if events & IOLoop.ERROR:
+           if reader:
+               reader.readConnectionLost(failure.Failure(error.ConnectionLost()))
+           if writer:
+               writer.connectionLost(failure.Failure(error.ConnectionLost()))
 
     def addReader(self, reader):
         """