From: Ben Darnell Date: Sun, 15 May 2011 05:35:23 +0000 (-0700) Subject: Fix a StackContext leak introduced by the delayed IOStream callbacks X-Git-Tag: v2.0.0~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3205b3682de94f907053b643aaf465560c52b6a4;p=thirdparty%2Ftornado.git Fix a StackContext leak introduced by the delayed IOStream callbacks --- diff --git a/tornado/iostream.py b/tornado/iostream.py index cb67f3ae4..38c1a2ba3 100644 --- a/tornado/iostream.py +++ b/tornado/iostream.py @@ -251,7 +251,13 @@ class IOStream(object): # non-reentrant mutexes # * Ensures that the try/except in wrapper() is run outside # of the application's StackContexts - self.io_loop.add_callback(wrapper) + with stack_context.NullContext(): + # stack_context was already captured in callback, we don't need to + # capture it again for IOStream's wrapper. This is especially + # important if the callback was pre-wrapped before entry to + # IOStream (as in HTTPConnection._header_callback), as we could + # capture and leak the wrong context here. + self.io_loop.add_callback(wrapper) def _handle_read(self): while True: