]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Crude fix for issue #855: automatically initiate SSL handshake in SSLIOStream. 856/head
authorAntoine Pitrou <solipsis@pitrou.net>
Wed, 17 Jul 2013 13:09:05 +0000 (15:09 +0200)
committerAntoine Pitrou <solipsis@pitrou.net>
Wed, 17 Jul 2013 13:09:05 +0000 (15:09 +0200)
Perhaps this should be exposed as an option instead?

tornado/iostream.py
tornado/test/iostream_test.py

index cd97f9d30d5a941a1bff9c9316876844592aba22..9b10dc2c83cdf5ee6f4df70a09a297be1ab3129a 100644 (file)
@@ -801,6 +801,10 @@ class SSLIOStream(IOStream):
         self._handshake_writing = False
         self._ssl_connect_callback = None
         self._server_hostname = None
+        self._initiate_handshake()
+
+    def _initiate_handshake(self):
+        self._add_io_state(self.io_loop.READ | self.io_loop.WRITE)
 
     def reading(self):
         return self._handshake_reading or super(SSLIOStream, self).reading()
index 24f8eef4c3eeb208147d8fd403fb672524d86b6e..0675c4f7a39c7c14d5cb0319de1b4727bb8fef45 100644 (file)
@@ -120,16 +120,6 @@ class TestIOStreamMixin(object):
 
         def accept_callback(connection, address):
             streams[0] = self._make_server_iostream(connection, **kwargs)
-            if isinstance(streams[0], SSLIOStream):
-                # HACK: The SSL handshake won't complete (and
-                # therefore the client connect callback won't be
-                # run)until the server side has tried to do something
-                # with the connection.  For these tests we want both
-                # sides to connect before we do anything else with the
-                # connection, so we must cause some dummy activity on the
-                # server.  If this turns out to be useful for real apps
-                # it should have a cleaner interface.
-                streams[0]._add_io_state(IOLoop.READ)
             self.stop()
 
         def connect_callback():