From 84acb204a6d33d683aac4455c23163d7c61b2e48 Mon Sep 17 00:00:00 2001 From: Ben Darnell Date: Sat, 25 Jun 2011 18:36:48 -0700 Subject: [PATCH] Fixed error in HTTPServer when AI_ADDRCONFIG is not available (as on WinXP) Closes #287 --- tornado/httpserver.py | 9 ++++++++- website/sphinx/releases.rst | 1 + website/sphinx/releases/next.rst | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 website/sphinx/releases/next.rst diff --git a/tornado/httpserver.py b/tornado/httpserver.py index 922232f6..7468b8bf 100644 --- a/tornado/httpserver.py +++ b/tornado/httpserver.py @@ -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) diff --git a/website/sphinx/releases.rst b/website/sphinx/releases.rst index 69606afc..6635bf39 100644 --- a/website/sphinx/releases.rst +++ b/website/sphinx/releases.rst @@ -4,6 +4,7 @@ Release notes .. toctree:: :maxdepth: 2 + releases/next releases/v2.0.0 releases/v1.2.1 releases/v1.2.0 diff --git a/website/sphinx/releases/next.rst b/website/sphinx/releases/next.rst new file mode 100644 index 00000000..13ead384 --- /dev/null +++ b/website/sphinx/releases/next.rst @@ -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