Fixed error in HTTPServer when AI_ADDRCONFIG is not available (as on WinXP)

Closes #287
This commit is contained in:
Ben Darnell 2011-06-25 18:36:48 -07:00
parent 5fde3f5f17
commit 84acb204a6
3 changed files with 20 additions and 1 deletions

View File

@ -183,8 +183,15 @@ class HTTPServer(object):
"""
if address == "":
address = None
flags = socket.AI_PASSIVE
if hasattr(socket, "AI_ADDRCONFIG"):
# AI_ADDRCONFIG ensures that we only try to bind on ipv6
# if the system is configured for it, but the flag doesn't
# exist on some platforms (specifically WinXP, although
# newer versions of windows have it)
flags |= socket.AI_ADDRCONFIG
for res in socket.getaddrinfo(address, port, family, socket.SOCK_STREAM,
0, socket.AI_PASSIVE | socket.AI_ADDRCONFIG):
0, flags):
af, socktype, proto, canonname, sockaddr = res
sock = socket.socket(af, socktype, proto)
flags = fcntl.fcntl(sock.fileno(), fcntl.F_GETFD)

View File

@ -4,6 +4,7 @@ Release notes
.. toctree::
:maxdepth: 2
releases/next
releases/v2.0.0
releases/v1.2.1
releases/v1.2.0

View File

@ -0,0 +1,11 @@
What's new in the next release of Tornado
=========================================
In progress
-----------
Bug fixes
~~~~~~~~~
* `HTTPServer`: fixed exception at startup when ``socket.AI_ADDRCONFIG`` is
not available, as on Windows XP