Skip to content

Commit

Permalink
Merge branch 'branch4.5' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
bdarnell committed Aug 27, 2017
2 parents 11ba169 + 810c341 commit ca6f171
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release notes
.. toctree::
:maxdepth: 2

releases/v4.5.2
releases/v4.5.1
releases/v4.5.0
releases/v4.4.3
Expand Down
10 changes: 10 additions & 0 deletions docs/releases/v4.5.2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
What's new in Tornado 4.5.2
===========================

Aug 27, 2017
------------

Bug Fixes
~~~~~~~~~

- Tornado now sets the ``FD_CLOEXEC`` flag on all file descriptors it creates. This prevents hanging client connections and resource leaks when the `tornado.autoreload` module (or ``Application(debug=True)``) is used.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def build_extension(self, ext):

kwargs = {}

version = "4.5.1"
version = "4.5.2"

with open('README.rst') as f:
kwargs['long_description'] = f.read()
Expand Down
4 changes: 2 additions & 2 deletions tornado/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
# is zero for an official release, positive for a development branch,
# or negative for a release candidate or beta (after the base version
# number has been incremented)
version = "4.5.1"
version_info = (4, 5, 1, 0)
version = "4.5.2"
version_info = (4, 5, 2, 0)
1 change: 1 addition & 0 deletions tornado/netutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def accept_handler(fd, events):
if errno_from_exception(e) == errno.ECONNABORTED:
continue
raise
set_close_exec(connection.fileno())
callback(connection, address)
io_loop.add_handler(sock, accept_handler, IOLoop.READ)

Expand Down
4 changes: 4 additions & 0 deletions tornado/platform/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ class Waker(interface.Waker):
and Jython.
"""
def __init__(self):
from .auto import set_close_exec
# Based on Zope select_trigger.py:
# https://github.com/zopefoundation/Zope/blob/master/src/ZServer/medusa/thread/select_trigger.py

self.writer = socket.socket()
set_close_exec(self.writer.fileno())
# Disable buffering -- pulling the trigger sends 1 byte,
# and we want that sent immediately, to wake up ASAP.
self.writer.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
Expand All @@ -54,6 +56,7 @@ def __init__(self):
# http://mail.zope.org/pipermail/zope/2005-July/160433.html
# for hideous details.
a = socket.socket()
set_close_exec(a.fileno())
a.bind(("127.0.0.1", 0))
a.listen(1)
connect_address = a.getsockname() # assigned (host, port) pair
Expand All @@ -78,6 +81,7 @@ def __init__(self):
a.close()

self.reader, addr = a.accept()
set_close_exec(self.reader.fileno())
self.reader.setblocking(0)
self.writer.setblocking(0)
a.close()
Expand Down
2 changes: 2 additions & 0 deletions tornado/tcpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from tornado.iostream import IOStream
from tornado import gen
from tornado.netutil import Resolver
from tornado.platform.auto import set_close_exec

_INITIAL_CONNECT_TIMEOUT = 0.3

Expand Down Expand Up @@ -202,6 +203,7 @@ def _create_stream(self, max_buffer_size, af, addr, source_ip=None,
# - 127.0.0.1 for IPv4
# - ::1 for IPv6
socket_obj = socket.socket(af)
set_close_exec(socket_obj.fileno())
if source_port_bind or source_ip_bind:
# If the user requires binding also to a specific IP/port.
try:
Expand Down

0 comments on commit ca6f171

Please sign in to comment.